Hi I have 2 problems 1. Hi I have written a blink LED code using Keil and programmed my core using secondary boot loader The problem is that my circuit works when I connect it to power, but when I reset the core using reset pin (apply a low), it stops working and does not restart until I disconnect and connect the power again I have used the start up code that keil adds to the project (lpc2300.s) and a simple code in (rowley.zendesk.com/.../61610-application-not-starting-up-from-reset-lpc2000) I read it may be caused by "start up after reset" not enabled, but I don't know how to fix that in keil?
2. I use the following code to for transmitting data using TXD2 (P0.10 in lpc2368) As you see the LED should blink in each executation. But the LED is turned on and never turns off. I think the code is stopped in while (!(U2LSR & 0x20)); Is my code correct? I use 12MHz crystal with PLL multiplier of 12, so my Fclk is 36MHz? and I set U2DLL=324 This is the code:
#include <LPC23xx.h> #define null_ch 0x0D void init_serial2 (void) { //Enable RxD2 and TxD2 P0.10=tx2, 11=rx2 PINSEL0 = 0x00500000; //8 bits, no Parity, 1 Stop bit ; Enable baud rate change U2LCR = 0x83; //9600 Baud Rate @ 36MHz VPB Clock U2DLL = 0xEA; //DLAB = 0 U2LCR = 0x03; } void delay(long int cycles) { long int i ; for(i=0;i<cycles;i++); } void putchar2 (unsigned char character) { if (character == '\n') { //while (!(U2LSR & 0x20)); //U2THR = null_ch; } while (!(U2LSR & 0x20)); U2THR = character; //return (U2THR = character); } int getchar2 (void) { while (!(U2LSR & 0x01)); return (U2RBR); } int main(void) { static unsigned long int counter; //unsigned char toggle; SCS |=0x00000001; FIO0DIR =0x0401; init_serial2(); while(1) { counter++; delay(1000000); FIO0SET = 0x1; putchar2(counter); //Echo terminal delay(1000000); FIO0CLR=1;// &= 0xFFFFFFFE; } }
Any help would be extremely appreciated
"I think the code is stopped in while (!(U2LSR & 0x20));"
Why do you think that? Or more specifically - why not test if that is so. Just avoid calling that function and you'll know.
By the way - the best way to test baudrates is to just send out characters and verify with an oscilloscope that you get exactly the baudrate you intended.
With even with incorrect baudrate, the UART will send out data so will be ready for more - it is only the receive side that will have serious issues with incorrect baudrates. Unless the baudrate is so off that the UART don't get a clock at all or gets overclocked.
Thanks Yes when I remove the while LED blinks continuously Unfortunately I don't have an oscilloscope, But I changed baud rate to 38400 on my computer and didn't get the data on my screen
How about the reset problem? do you have any idea/solution?