Forums

UART Problem

Started by mobilsiten March 2, 2005

I cant get this to work. I only want to turn on a led if I recive
something on UART1.
This is the code:

void init_serial (void) // Initialize Serial Interface
{
unsigned dummy;
unsigned short baud = 9600, baud_rate;

PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */

U1LCR = 0x0D3; /* 8 bits, no Parity, 1 Stop bit */
U1IER = 0; /* Disable UART1 Interrupts */

VICVectAddr0 = (unsigned long)ElsyIRQ;
VICVectCntl0 = 0x20 | 7; /* UART1 Interrupt */
VICIntEnable = 1 << 7; /* Enable UART1 Interrupt */

baud_rate = UART_BAUD(baud);
U1DLL = (signed char)(baud_rate); //LSB
U1DLM = (signed char)((baud_rate) >> 8); //MSB
U1LCR = 0x00000003; // DLAB = 0

dummy = U1IIR; /* Read IrqID - Required to Get Interrupts Started */
U1IER = 3; /* Enable UART1 RX and THRE Interrupts */

}

void ElsyIRQ (void)
{
IOSET1 = 0x000F0000; // Turn on LEDs
VICVectAddr = 0x00000000;
}

Can someone please help me?



An Engineer's Guide to the LPC2100 Series


--- In , "mobilsiten" <petertholander@h...> wrote:
>
> I cant get this to work. I only want to turn on a led if I recive
> something on UART1.
> This is the code:
>
> void init_serial (void) // Initialize Serial Interface
> {
> unsigned dummy;
> unsigned short baud = 9600, baud_rate;
>
> PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */
>
> U1LCR = 0x0D3; /* 8 bits, no Parity, 1 Stop bit */
> U1IER = 0; /* Disable UART1 Interrupts */
>
> VICVectAddr0 = (unsigned long)ElsyIRQ;
> VICVectCntl0 = 0x20 | 7; /* UART1 Interrupt */
> VICIntEnable = 1 << 7; /* Enable UART1 Interrupt */
>
> baud_rate = UART_BAUD(baud);
> U1DLL = (signed char)(baud_rate); //LSB
> U1DLM = (signed char)((baud_rate) >> 8); //MSB
> U1LCR = 0x00000003; // DLAB = 0
>
> dummy = U1IIR; /* Read IrqID - Required to Get Interrupts Started */
> U1IER = 3; /* Enable UART1 RX and THRE Interrupts */
>
> }
>
> void ElsyIRQ (void)
> {
> IOSET1 = 0x000F0000; // Turn on LEDs
> VICVectAddr = 0x00000000;
> }
>
> Can someone please help me?

Hmm, very strange! Now it works without any changes....

Thanks anyway!



A quick observation; the IO pin direction will most likely need to be set
as an output and it's function may possibly need to be set to GPIO.

Regards
-Bill Knight
R O SoftWare &
http://www.theARMPatch.com

On Wed, 02 Mar 2005 09:19:55 -0000, mobilsiten wrote:
I cant get this to work. I only want to turn on a led if I recive
something on UART1.
This is the code:

void init_serial (void) // Initialize Serial Interface
{
unsigned dummy;
unsigned short baud = 9600, baud_rate;

PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */

U1LCR = 0x0D3; /* 8 bits, no Parity, 1 Stop bit */
U1IER = 0; /* Disable UART1 Interrupts */

VICVectAddr0 = (unsigned long)ElsyIRQ;
VICVectCntl0 = 0x20 | 7; /* UART1 Interrupt */
VICIntEnable = 1 << 7; /* Enable UART1 Interrupt */

baud_rate = UART_BAUD(baud);
U1DLL = (signed char)(baud_rate); //LSB
U1DLM = (signed char)((baud_rate) >> 8); //MSB
U1LCR = 0x00000003; // DLAB = 0

dummy = U1IIR; /* Read IrqID - Required to Get Interrupts Started */
U1IER = 3; /* Enable UART1 RX and THRE Interrupts */
void ElsyIRQ (void)

IOSET1 = 0x000F0000; // Turn on LEDs
VICVectAddr = 0x00000000; Can someone please help me?
Yahoo! Groups Links



Yes, sorry I did that in the main function...

--- In , "Bill Knight" <BillK@t...> wrote:
> A quick observation; the IO pin direction will most likely need to
be set
> as an output and it's function may possibly need to be set to GPIO.
>
> Regards
> -Bill Knight
> R O SoftWare &
> http://www.theARMPatch.com >
>
> On Wed, 02 Mar 2005 09:19:55 -0000, mobilsiten wrote: >
> I cant get this to work. I only want to turn on a led if I recive
> something on UART1.
> This is the code:
>
> void init_serial (void) // Initialize Serial Interface
> {
> unsigned dummy;
> unsigned short baud = 9600, baud_rate;
>
> PINSEL0 = 0x00050000; /* Enable RxD1 and TxD1 */
>
> U1LCR = 0x0D3; /* 8 bits, no Parity, 1 Stop bit */
> U1IER = 0; /* Disable UART1 Interrupts */
>
> VICVectAddr0 = (unsigned long)ElsyIRQ;
> VICVectCntl0 = 0x20 | 7; /* UART1 Interrupt */
> VICIntEnable = 1 << 7; /* Enable UART1 Interrupt */
>
> baud_rate = UART_BAUD(baud);
> U1DLL = (signed char)(baud_rate); //LSB
> U1DLM = (signed char)((baud_rate) >> 8); //MSB
> U1LCR = 0x00000003; // DLAB = 0
>
> dummy = U1IIR; /* Read IrqID - Required to Get Interrupts Started */
> U1IER = 3; /* Enable UART1 RX and THRE Interrupts */ >
> void ElsyIRQ (void)
>
> IOSET1 = 0x000F0000; // Turn on LEDs
> VICVectAddr = 0x00000000; > Can someone please help me? >
> Yahoo! Groups Links