Forum : 8051
Original Post
Post Information | Post |
---|---|
February 14, 2008 - 2:41pm
|
Using build 747-51 for the upsd3400 Just started a new project after not using the Ride for a year or so. The following fails static char EncStr[ 40 ]; void ProcessEncoder(void ) a = 1; } What I get in the buffer is "test " followed by the character '6' 255 times. I have tried a variety of options and always get the '6'. I have increased the (s)print buffer size in the linker options to 64 so its bigger than the EncStr. This is no different that commands I have used in previous projects, so has there been a change in the compiler?? |
Check in "Options | Project | LX51 | Linker | (s)printf buffer size".
The default value is '16' and there is no problem when running your simple program.
The behaviour you described could be produced by changing the default by '0' for example. Keep '16' and it should work.
Let me know if the problem is there. Thanks.
Regret this didn't work.
I have sent you the project file direct.
I started your application in simulation, and after the initialization, I set PC = the line where the sprintf is coded. It works as expected in simulation (both the sprintf and the write_page function that follows).
Therefore I guess that you have:
1. Either a problem with LCD display,
2. Or a issue with interrupt that I do not reproduce here in simulation.
Problem identified in discussion with Francis Lamotte.
The project used the LARGE model and I had specified external stack.
There is some slightly contradictory advice if you click Help in Options/Project/RC51 on the Memory Model page. It starts by saying
“it is necessary to use an external stack (in xdata) for LARGE, COMPACT or HUGE model applicationsâ€
and goes on to state
“However, external stack use for SMALL, COMPACT and LARGE models is optional.â€
Buried in the startup.a51 file is a commentfrom ST that states
;-------------------------------------------------------------------------------
; 9. If selected, initialize the external stack.
;-------------------------------------------------------------------------------
; For uPSD33xx and uPSD34xx DO NOT USE THE EXTERNAL STACK!!!!
;-------------------------------------------------------------------------------
i.e. it doesn't work.
de-selecting it and scanf works. Wounder what else didn't?
More information about this issue:
The external stack is located in the "pdata" space (using MOVX @Ri instructions). For most of the 8051 derivatives, the pdata MSB address is defined by the value stored in the P2 latch. For some specific devices, P2-latch is replaced by either a fixed value (FF or 00) , for some others, it is replaced by s specific SFR. This is normally well managed by the linker (startup selection and configuration). In the case of the uPST33xx and uPSD34xx, the pdata (MOVX @Ri instructions) is NOT supported by the device. Therefore, the external stack is NOT supported. We will document this more precisely.