> I'm just trying to write my first C8051 program: > > __sfr __at(0xa0) P2; > __sfr __at(0xa6) P2MDOUT; > __sfr __at(0xe2) XBR1; > > unsigned long int u = 0; > #define u 0ul > > void main(void) > { > // Enable port output > XBR1 = 0x40; > P2MDOUT = 0x0c; > > for(;;) > P2 = ((u / 10) & 0x03) << 2; > } > > My board has LED on the P2.2 and P2.3. This program turns them off. But > when I remove the "#define u 0ul" line the LEDs are on. > I compile using > sdcc test.c > and put the program onto the µC using > ec2writeflash --port USB --hex /tmp/test.ihx > > Philipp > > P.S.: Using > sdcc 3.6.2 #9727
Something that every SiLabs C8051Fxxx user bumps into as the first issue is that the watchdog is enabled by default at shortest interval and that our crt routines take longer than this interval. You should add an _sdcc_external_startup() function that disables the watchdog. Some have the watchdog in the PCA and some have a seperate one. unsigned char _sdcc_external_startup(void) { WDTCN = 0xde; WDTCN = 0xad; // Disable watchdog timer on e.g. C8051F120 PCA0MD &= ~0x40; // WDTE = 0 on e.g. C8051F340 return 0; // perform normal initialization } Maarten ------------------------------------------------------------------------------ _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user