While LED blinking and timer interrupts re working now, I wasn't able to get serial I/O to work yet. I only see garbage (all received bytes are either 0x00 or 0x80). I tried to port my "Hello, world!" that I already got working for many other mcs51 variants:
#include <stdio.h> #include <C8051F120.h> int putchar(int c) { while(!(SCON0 & 0x02)); SCON0 &= ~0x02; SBUF0 = c; return (c); } unsigned char _sdcc_external_startup(void) { // Disable watchdog timer WDTCN = 0xde; WDTCN = 0xad; return 0; // perform normal initialization } void main(void) { unsigned long int i = 0; // Initialize I/O pins SFRPAGE = 0xf; XBR0 = 0x04; // UART0 on P0.0 and P0.1 P0MDOUT = 0x01; // Set port P0.0 (Uart tx) to push-pull XBR2 = 0x40; // Enable crossbar // Configure UART for 300 baud, 8 data bits, 1 stop bit. SFRPAGE = 0x0; TMOD = 0x20; SCON0 = 0x40; TH1 = 45; TCON |= 0x40; SCON0 |= 0x02; // Tell putchar() the UART is ready to send. for(;;) { printf("Hello World!\n"); for(i = 0; i < 147456; i++); // Sleep } } I've tried to different serial-to-usb converters (one attached to the R232 header on the board, the other directly to the Tx pin) and multiple baudrates. Philipp ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user