Hi , I'm newbee to ARM controller family.I'm trying to Receive a Message from GPS(Global Positioning System) and Sending to an GSM modem.
I'M using LPC2148 controller. My freq for controller is 12MHz. I need Help on how to intialize both the UARTs.
My code for Intilization is written as fallows,
void SerialInit1 (void) // this intialization for transmitting a msg to GSM modem { PINSEL0 = 0x00050000; // Enable RxD1 and TxD1 (for UART1) U1LCR = 0x00000083; // 8 bits, no Parity, 1 Stop bit U1DLL = 0x000000C2; // 9600 Baud Rate @ 30MHz VPB Clock U1LCR = 0x00000003; // DLAB = 0 } void SerialInit0 (void) // this intialization for receiving msg from GPS { PINSEL0 = 0x00000005; // Enable RxD1 and TxD1 (for UART1) U0LCR = 0x00000083; // 8 bits, no Parity, 1 Stop bit U0DLL = 0x000000C2; // 9600 Baud Rate @ 30MHz VPB Clock U0LCR = 0x00000003; // DLAB = 0 }
I doubt this is not the the proper way of intializing the Both UARTs..Can someone throw light on it?
Thank you Regards, Kush
Why do you doubt it?
One way to clear doubts, rather than using meaningless "magic numbers" like
PINSEL0 = 0x00000005;
Is to use symbolic constants with meaningful names.
Suggestion Accepetd...But the thing is if I intilalize both, I'm not getting anything out of serial window..If I mask receiving intialization ( SerialInit1( ) )I'm getting the desired output.I mean I can transmit ....But how about receiving?
What do you think happens when you do two writes to the same register? Do you think the first write survives?
If you want to set or clear specific bits in a register, you should use and (&) + or (|) instead of full writes that affects all 32 bits.
That depends on how the register works. Don't know about the LPCs, but e.g. Atmel uses a pushbutton-like function with separate enable and disable registers, where
set_pin_output_on = 0x00000001; set_pin_output_on = 0x00000002;
will result in the output being turned on for both pin 0 and pin 1.
I guess it's datasheet time.
Yes, the LPC have some registers with Set and Clear in the names. This is mostly for GPIO output values and for interrupt enable registers. For GPIO output state, you also have a direct-write register, so the software can select what is most efficient for every situation.
PINSEL0, on the other hand, does not have any set/clear alternatives so it's up to the software to modify the bits as needed without destroying other bits.
Thanks Mr Westermark ....
As you mentioned, that is the problem with my code.It's working fine now...Thanks for all who stepped in for helping me..
Kush