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 - Formatted strings in C code generate

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

Formatted strings in C code generate (by Alessandro)
Firstly thanks for shared this code to others...

I trying to change the C source code generator to support the send of strings over serial line.

The resulting C code send the characters over serial line but i receive always zeros. In the simulate or PIC code generator the same format string works fine, so i think something is missing in the C code version in to work fine.

See attached my version of ansic.cpp, line 364.

Thanks.
Mon Jun 28 2010, 09:06:37, download attachment ansic.cpp
(no subject) (by Jonathan Westhues)
Why do you write the character I_scratch2?

The INT_UART_SEND op accepts an integer input variable, IntCode[i].name1, which contains the character to be sent, and a bit variable, IntCode[i].name2.

If the bit variable is true, then the character will be sent. If not, then the instruction is a no-op. On return, the integer variable is unchanged, and the bit variable is true if the UART is busy, and false if it is ready to accept a new character.
Mon Jun 28 2010, 09:16:44
(no subject) (by Alessandro)
Ok, as his explanation i change the code to:

case INT_UART_SEND:
fprintf(f, "%s = RS232Write(%s);\n", MapSym(IntCode[i].name2), MapSym(IntCode[i].name1));
break;


RS232Write always return false (never busy) because wait character will be send. This is possible because cycle time is slow enough (10ms) to send 1 character at 115200:

unsigned int RS232Write(unsigned int c)
{
while (!(UART0->LSR & 0x20) ); /* THRE status, contain valid data */
UART0->THR = (char)c;
while (!(UART0->LSR & 0x20) );

return 0;
}

The resulting in serial line is:

\0x003\0x00=\0x00=\0x00=\0x00=\0x00
\0x00\0x00
\0x00
\0x003\0x00=\0x00=\0x00=\0x00=\0x00
\0x00\0x00
\0x00
\0x00
\0x00
\0x00
\0x00
\0x00
\0x00
\0x00
\0x00
\0x00
\0x00
\0x00
\0x003\0x00=
\0x00=\0x00=\0x00=\0x00
\0x00\0x00

The PIC or the simulator has some control variables that I did not understand exactly how they work, is this missing some variable control here too.

I check the baudrate sending a plain text bypass C source code and it's ok.

Please, see attached ld.c generated.

Thank you very much.
Mon Jun 28 2010, 10:18:33, download attachment ld.c
(no subject) (by Alessandro)
Attached LDmicro serial project used to generate the C source code.
Mon Jun 28 2010, 10:23:00, download attachment serial.ld
uart communication (by maximus)
can any body give me sample program for uart communication for more of 4 avr ,,,? like modbus master and slave...?
please......
Mon Oct 3 2011, 02:42:58
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):