Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
03/13/09 13:13
Read: times


 
#163420 - Can you have a look at this?
Responding to: ???'s previous message
Thanks for all your comments. I agree that finding another consultant or even buying Keil might well have been cheaper and quicker overall, but I just had to find out what was wrong. I expect everyone here knows that feeling! In terms of validation, of course we have a test protocol that we wrote when the original software was commissioned, and we'd follow that any time there was a change, however trivial.

On to more technical matters, I think I have found the problem. Does the following look odd to you?

Here's the source; it's setting a register in extended memory. At MCU reset, the register is zero so it should end up with 0x0c in that register.
#define bMODECNFG   (* (unsigned char xdata *)0xFFFB)        
#define MODECNFG_CLKOUTEN 0x04  
#define MODECNFG_CLKSLCT 0x08   
...                                
bMODECNFG |= MODECNFG_CLKOUTEN;
bMODECNFG |= MODECNFG_CLKSLCT;
...

 

(ignore the fact it's not the most concise way to do this!)

Code generated by SDCC:
                            444 ;	bMODECNFG |= MODECNFG_CLKOUTEN;
   004B 7A FB               445 	mov	r2,#0xFB
   004D 7B FF               446 	mov	r3,#0xFF
   004F 90 FF FB            447 	mov	dptr,#0xFFFB
   0052 E0                  448 	movx	a,@dptr
   0053 FC                  449 	mov	r4,a
   0054 74 04               450 	mov	a,#0x04
   0056 4C                  451 	orl	a,r4
   0057 8A 82               452 	mov	dpl,r2
   0059 8B 83               453 	mov	dph,r3
   005B F0                  454 	movx	@dptr,a
                            455 ;	bMODECNFG |= MODECNFG_CLKSLCT;
   005C 90 FF FB            456 	mov	dptr,#0xFFFB
   005F 43 04 08            457 	orl	ar4,#0x08
   0062 EC                  458 	mov	a,r4
   0063 F0                  459 	movx	@dptr,a

 

This (as far as I can see) results in 0x04 in the register.

Equivalent dissassembled from the Keil version:
X10be:	mov	dptr,#Xfffb
	movx	a,@dptr
	orl	a,#4
	movx	@dptr,a
	movx	a,@dptr
	orl	a,#8
	movx	@dptr,a

 

This looks a lot more sensible (and shorter!)

I changed the source to
bMODECNFG |= (MODECNFG_CLKOUTEN|MODECNFG_CLKSLCT);
 

and it now works perfectly on SDCC.

Do you agree this is a bug in SDCC's code generation?



List of 26 messages in thread
TopicAuthorDate
SDCC and Keil and I/O            01/01/70 00:00      
   No big changes for SDCC            01/01/70 00:00      
   Nothing obvious            01/01/70 00:00      
   just curious            01/01/70 00:00      
      Just what do you mean, Erik?            01/01/70 00:00      
         even the SDCC 'friends' agree            01/01/70 00:00      
         Answers to your quiz            01/01/70 00:00      
            5th            01/01/70 00:00      
            But the really difficult question is...            01/01/70 00:00      
      Thanks! and a bit of background            01/01/70 00:00      
         Am I going crazy?            01/01/70 00:00      
         Is the code large then 2K?            01/01/70 00:00      
            Keil deserves a medal if it is using USB in less than 2kB            01/01/70 00:00      
               Keil probably has nothing to do with the USB?            01/01/70 00:00      
                  If only it where that simple            01/01/70 00:00      
                  TUSB3410            01/01/70 00:00      
         Test costs?            01/01/70 00:00      
   Initially maintain a compatible source            01/01/70 00:00      
      But            01/01/70 00:00      
   Can you have a look at this?            01/01/70 00:00      
      use "__xdata volatile unsigned char __at(0xfffb) bMODECNF"            01/01/70 00:00      
         Done!            01/01/70 00:00      
            thanks            01/01/70 00:00      
      register bank, ar4?            01/01/70 00:00      
   A free 3-month full Keil PK51 licence            01/01/70 00:00      
      Thanks for the link!            01/01/70 00:00      

Back to Subject List