So I purchased the LPC-P2103 from Sparkfun, coming from a PIC background I thought it would be fun to mess around with the ARM processor. Anyway I compiled some code using uVision, just a simple program to send a string over the serial port to the PC. I compiled the program to a hex file and loaded it using Flash Magic. I then removed the BSL jumper and reset the gear and nothing comes over the serial port. I don’t know maybe I am doing something stupid but I was hoping you guys could help. I have included the code below. Any thoughts?
#include <stdio.h> /* standard I/O .h-file */
#include <LPC21xx.H> /* LPC21xx definitions */
extern void init_serial (void); /* Initialize Serial Interface */
void sendhex (int hex) { /* Write Hex Digit to Serial Port */
if (hex > 9) putchar('A' + (hex - 10));
else putchar('0' + hex);
}
void sendstr (char *p) { /* Write string */
while (*p) {
putchar (*p++);
}
}
int main (void) {
init_serial();
sendstr("Hello World\n");
}
#include <LPC21xx.H> /* LPC21xx definitions */
#define CR 0x0D
void init_serial (void) { /* Initialize Serial Interface */
PINSEL0 = 0x00000005; /* Enable RxD1 and TxD1 */
U0LCR = 0x83; /* 8 bits, no Parity, 1 Stop bit */
U0DLL = 0x60; /* 9600 Baud Rate @ 15MHz VPB Clock */
U0LCR = 0x03; /* DLAB = 0 */
}
int putchar (int ch) { /* Write character to Serial Port */
if (ch == '\n') {
while (!(U0LSR & 0x20));
U0THR = CR; /* output CR */
}
while (!(U0LSR & 0x20));
return (U0THR = ch);
}
int getchar (void) { /* Read character from Serial Port */
while (!(U0LSR & 0x01));
return (U0RBR);
}