We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Using a keil mcb2300 with lpc2378.
Used the NXP example bundle uart code as the base and attempting to modify it to use all four uarts via interrupts. Couldn't find any examples that use all four uarts on lpc2300.
zip of base project www.alexthegeek.com/.../testUsarti.zip code www.alexthegeek.com/.../
The uart init routines run and print out their message on uart0. uart0 and uart1 work and echo back characters when initalised in order 0,1,2,3 but not uart2 and 3.
Most likely I'm doing something dumb or missing something simple. Any hints or pointers appreciated.
Not sure on the pinsel settings as its been a while since I've used lpc2000's (mostly xilinx , avr and st32f lately)
Thank you
Alex
pinsel
/* PinSelect and Pinmode settings */ /* UART0 = COM1 DB9 P4 on mcb2300 */ /* UART1 = COM1 DB9 P3 on mcb2300 */ /* UART2 = COM 2 is on IDC (TXD2=P2.8 (93), RXD2=P2.9 (92), GND=GND (103) */ /* UART3 = COM3 is on IDC (TXD3 = P0.0 (66), RXD3 = P0.1 (67), GND=GND (42) */ PINSEL0 = 0x4000005A; /* binary: 01000000_00000000_00000000_01011010 */ PINMODE0 = 0x800000AA; /* binary: 10000000_00000000_00000000_10101010 */ // IO0DIR = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ PINSEL1 = 0x00000001; /* binary: 00000000_00000000_00000000_00000001 */ PINMODE1 = 0x0000000A; /* binary: 00000000_00000000_00000000_00001010 */ PINSEL2 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ PINMODE2 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ // IO1DIR = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ PINSEL3 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ PINMODE3 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ PINSEL4 = 0x000A0000; /* binary: 00000000_00001010_00000000_00000000 */ PINMODE4 = 0x000A0000; /* binary: 00000000_00001010_00000000_00000000 */ // PINSEL4 = 0x000A000A; // binary: 00000000_00001010_00000000_00001010 FIO2DIR = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ PINSEL6 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ PINMODE6 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ FIO3DIR = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ PINSEL7 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ PINMODE7 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ PINSEL8 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ PINMODE8 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ FIO4DIR = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ PINSEL9 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */ PINMODE9 = 0x00000000; /* binary: 00000000_00000000_00000000_00000000 */
Great when the defines for the symbolic names are correct. A right pain in the proverbial when you blindly trust them and find they're not!
It is quite often that the supplied header files only have register names. So I normally create my own constants for the individual bits/bit fields of the registers.
Next thing is that initialization of the port pins for an UART should not make direct writes to the configuration registers - the registers contains bits for many other pins that are likely to be used by other parts of the code. So it is way better to mask out and set only the bits that are relevant for the UART.
I think maintaining the manual hex-to-binary translations is likely to be a greater risk...