Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] PIC18F4550 unable to do per-byte addressing (mikroC PRO)

Status
Not open for further replies.
The sprintf function uses variable argument list (va_start,va_arg,va_end...).
It seems that the sprintf pops from the stack 2bytes (0xba, 0xdc, 0x?0, ...) for each %c.
That meens that it thinks that every char has 2 byte width.
It may be an option of the compiler or you may have wrong library version.

Try this code and tell me the results:

Code:
   sprintf(txt,"%c %c %c %c\r\n",(int)a,(int)b,(int)c,(int)d);
 
The sprintf function uses variable argument list (va_start,va_arg,va_end...).
It seems that the sprintf pops from the stack 2bytes (0xba, 0xdc, 0x?0, ...) for each %c.
Embedded C compilers don't necessarily use the stack for passing arguments. It's unlikely particularly for 8-bit PICs due to limited stack space.
 

The sprintf function uses variable argument list (va_start,va_arg,va_end...).
It seems that the sprintf pops from the stack 2bytes (0xba, 0xdc, 0x?0, ...) for each %c.
That meens that it thinks that every char has 2 byte width.
It may be an option of the compiler or you may have wrong library version.

Try this code and tell me the results:

Code:
   sprintf(txt,"%c %c %c %c\r\n",(int)a,(int)b,(int)c,(int)d);

Thanks. It works. Take a look:
solutiontemp.png

I am not closing the topic because I suspect that I have experienced a similiar issue with the different function, but I don't know more now.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top