Home
Prox / RFID
Verichips
Ladder Logic
[interfacing] †
Tube Joints
Key Code From Photo
SolveSpace (3d CAD)
SketchFlat (2d CAD)
Photographs
Miscellany
Resume / Consulting
Contact Me

LDmicro Forum - How a Subroutine impacts code execution

(you are viewing a thread; or go back to list of threads)

How a Subroutine impacts code execution (by Carey)
I've written a program that initializes a HD44780 (16x2) LCD in 4-bit parallel mode and then writes the letter "H". This works fine in the file 1602LCDKeypadV1_4_1.ld.

I then added a subroutine and placed the LCD initialization logic in there so it can be called once at startup and the remaining logic will write the message (the letter "H"(0x48h). This is the file 1602LCDKeypadV1_5.ld

When I run the simulation on both sets of code they seem to function identically but when I download it to my ATMega328P the V1_4_1 code works and the V1_5 will not.

Can anyone tell me if this is due to the way I'm using the subroutine function? If not do you have any suggestions on how to troubleshoot this issue.

Thanks, Will post the second file in a follow up post
Wed Jul 21 2021, 18:51:01, download attachment 1602LCDKeypadV1_4_1.ld
(no subject) (by Carey)
This is the second file from my previous post that uses a subroutine to separate my LCD initialization code from the code that generates a display message
Wed Jul 21 2021, 18:53:48, download attachment 1602cDKeypadV1_5.ld
(no subject) (by paulino Calubert)
I DO NOT UNDERSTAND VERY WELL WHAT YOU WANT. Do you use 2 chic (CPU) or do you use 1 Chic (CPU) and screen (LCD), if you use a chic (CPU) and Screen, if it is the latter, there is already a .hex software in LDMicro to handle the 4-line 20-segment screen that you can also display 2 lines 20segmentos. it does it by TX / RX 2 wires.
I pass you linz,

https://github.com/LDmicro/LDm...CD-based-on-HD44780-controller

with this you only have to place the string in UART format in your TX / RX program.
Thu Jul 22 2021, 05:01:57
(no subject) (by paulino Calubert)
Hello notice in the configuration bits of the (CPU).
in V.4 you have the configuration bits 0x2E6510EE0.
in V.5 you have the configuration bits 0xE75858340
For this it does not work for you, correct it and it will work for you as in v.4
tell me if it worked for you

Hola date cuenta en los Bits de configuración de la (CPU).
en el V.4 tienes los bits de configuración 0x2E6510EE0.
en V.5 tienes los bits de configuración 0xE75858340
Fri Jul 23 2021, 06:49:52
(no subject) (by Carey)
Hi Paulino,

I'm not sure what you mean by configuration bits. Can you explain this? I'm pretty new to working with these platforms so any help is appreciated. Thanks for the help.

-Carey
Sun Jul 25 2021, 19:52:16
(no subject) (by calubert paulino)

https://github.com/LDmicro/LDmicro/wiki/PIC-Configuration-Bits.

Here I put the inz, a question: this program that you are doing is to communicate the lcd screens by ports and not use uart, if it is as I mention it interests me and I can help the project. Since I do it by uart 2 wires (cables), but I always have to place another chic one and I would like not to use 2 chic ones, since I work with the atmega 2560 that has enough internal memory and I already prepared a PCB for it. atmega2560
Mon Jul 26 2021, 11:09:58
(no subject) (by Carey)
Hi, I'm using 4 bits on a port to control the data lines and 2 additional outputs as the control lines for switching between programming and data modes (RS) and the enable (EN) line loads each 4-bit hex code into the LCD registers. Once the LCD is initialize, you can load messages, select commands (clear display, switch between display lines, change cursor).

I cannot figure out what is meant by the previous post about cpu configuration bits. Since I'm using an AVRMega328P (Arduino Uno), I cannot set or change the cpu configuration bits from LDMicro, so I'm not sure how to check the difference as mentioned in this previous post:

"Hello notice in the configuration bits of the (CPU).
in V.4 you have the configuration bits 0x2E6510EE0.
in V.5 you have the configuration bits 0xE75858340
For this it does not work for you, correct it and it will work for you as in v.4
tell me if it worked for you"

Can you explain this in more detail for me? Thank you.
Mon Jul 26 2021, 20:12:31
(no subject) (by Calubert Paulino)
If you look at the 2 programs uploaded in this porti forum: 1602LCDKeypadV1_4_1.ld and 1602cDKeypadV1_5.ld,

They have different bits, if one of them works for you as you say I think v4 you say it works, there are several solutions,
Option 1, open the program that works for you and in that same program put the modifications that you made in v5.
Option 2, when you open the program in the (Configuration) tab, open it, clicking and a window opens, click (MCU Parameters) or You can open it directly by touching the keys (ALT-GR + F5) and you will see the boxes, in the box (There are configuration bits, you can copy the Bits of your v.4 program and paste it into the V5 program. Or write these Bits that are the ones that I saw in your V.4 program would be these 0x2E6510EE0,

NOTE: it is the window where we modify the frequency, Timer, cycle time, ETC,

I don't use arduino, but I use arduino boards with LDMicro .hex software (machine code) note: with this I want to imply that I use the arduino board as a Boar PCB and it works for me.

Si te fijas en los 2 programas cargados en este foro porti: 1602LCDKeypadV1_4_1.ld y 1602cDKeypadV1_5.ld,

Tienen diferentes los bits,si te funciona uno de ellos como comentas creo que v4 dices que funciona,hay varias soluciones,
opción 1º, abre el programa que te funciona y en ese mismo programa pon las modificaciones que hicistes en el v5.
opción 2º,cuando abres el programa en la pestaña de (Configuración) ábrela, clicando y se abre una ventana, clica (MCU Parámetros) o Puedes abrirlo directo Tocando las teclas (ALT-GR + F5) y veras las casillas, en la casilla (Bits de configuración hay puedes copiar los Bits del tú programa v.4 y pegarlo en el programa V5. o escribir estos Bits que son los que yo vi en tu programa V.4 serían estos 0x2E6510EE0,

NOTA: es la ventana que modificamos la frecuencia,Timer, tiempo de ciclo, ETC,

yo no uso arduino, pero uso las placas de arduino con el software LDMicro .hex (código maquina) nota: con esto quiero dar a entender que uso la placa de arduino como Boar PCB y me funciona.
Tue Jul 27 2021, 04:36:53
Post a reply to this comment:
Your Name:
Your Email:
Subject:
(no HTML tags; use plain text, and hit Enter for a line break)
Attached file (if you want, 5 MB max):