Hi Wolfgang,
Thanks for the reply.
It's indeed essential to set the pcon first I did it at later time. So
my
registers wher only valid the second tim I initialised the uart.
Thanks
thanks martijn
_____
From: l... [mailto:l...] On Behalf Of
c...@gmx.net
Sent: donderdag 22 januari 2009 11:19
To: l...
Subject: [lpc2000] Re: LPC2468 uart 2 and 3 not running
Turning on the Power in PCONP should be the first thing you do, otherwise
the registers might not be accessable. UART0 and 1 are turned on
automatically on reset while 2 and 3 are not, I guess thats why 0 and 1 are
working for you.
kind regards
Wolfgang
Hi All,
>
>I'm trying to get all the uarts on the 2468 running. Uart 0 and 1 are
>running.
>
>Uart 1 and 2 not.
>
>I execute the same code for all 4 uart channels. With the exeption off
>course that the registers are different in number (U0LCR becomes U2LCR
etc).
>I've set the pinmode register to diable pullups
see below. But still not
>running.
>
>If I halt the cpu I can see that its waiting for :
>
> while ((U2LSR & 0x20) == 0); // wait for TX buffer to empty
>
> U2THR = ch;
>
>BTW no TX ISr is used for now.
>
>What can it be that I'm missing??
>
>Please advice
>
>void UARTInitialize( char Port, unsigned int baud){
>
> unsigned int divisor = get_uart_clk(Port, OSCILLATOR_CLOCK_FREQUENCY) /
>(16 * baud);
>
> /* Configure UART */
>
> switch(Port)
>
> {
>
> case 0: // Radio channel 0
>
> U0LCR = U0LCR_Divisor_Latch_Access_Bit|0x03; /* 8 bit, 1 stop bit,
>no parity, enable DLAB */
>
> U0DLL = divisor & 0xFF;
>
> U0DLM = (divisor > > 8) & 0xFF;
>
> bit_clear(U0LCR, U0LCR_Divisor_Latch_Access_Bit_BIT); /* Disable DLAB
>*/
>
> bit_set(PINSEL0,4); //p0.2
>
> bit_clear(PINSEL0,5);
>
> bit_set(PINSEL0,6); //p0.3
>
> bit_clear(PINSEL0,7);
>
> // Turn power on to UART 0.
>
> bit_set(PCONP, PCONP_PCUART0_BIT);
>
> U0FCR = U0FCR_FIFO_Enable|U0FCR_Rx_FIFO_Reset;
>
> /* Setup UART interrupt */
>
> ctl_set_isr(6, 0, CTL_ISR_TRIGGER_FIXED, uart0ISR, 0);
>
> ctl_unmask_isr(6);
>
>#ifdef USART0_TX_INT_MODE
>
> bufferInit(&usart0_tx_ringbuf, &usart0_tx_buffer[0],
>sizeof(usart0_tx_buffer));
>
> usart0_tx_running = 0;
>
> bit_set(U0IER, U0IER_THRE_Interrupt_Enable_BIT);
>
>#endif
>
>#ifdef USART0_RX_INT_MODE
>
> // initialize data queues
>
> bufferInit(&usart0_rx_ringbuf, &usart0_rx_buffer[0],
>sizeof(usart0_rx_buffer));
>
> // enable receiver interrupts
>
> bit_set(U0IER, U0IER_RBR_Interrupt_Enable_BIT);
>
>#endif
>
> break;
>
> case 1: // Radio channel 1
>
> U1LCR = U1LCR_Divisor_Latch_Access_Bit|0x03; /* 8 bit, 1 stop bit,
>no parity, enable DLAB */
>
> U1DLL = divisor & 0xFF;
>
> U1DLM = (divisor > > 8) & 0xFF;
>
> bit_clear(U1LCR, U1LCR_Divisor_Latch_Access_Bit_BIT); /* Disable DLAB
>*/
>
> bit_set(PINSEL0,30); //p0.15
>
> bit_clear(PINSEL0,31);
>
> bit_set(PINSEL1,0); //p0.16
>
> bit_clear(PINSEL1,1);
>
> // Turn power on to UART 1.
>
> bit_set(PCONP, PCONP_PCUART1_BIT);
>
> U1FCR = U1FCR_FIFO_Enable|U1FCR_Rx_FIFO_Reset;
>
> /* Setup UART RX interrupt */
>
> ctl_set_isr(7, 0, CTL_ISR_TRIGGER_FIXED, uart1ISR, 0);
>
> ctl_unmask_isr(7);
>
>#ifdef USART1_TX_INT_MODE
>
> bufferInit(&usart1_tx_ringbuf, &usart1_tx_buffer[0],
>sizeof(usart1_tx_buffer));
>
> usart1_tx_running = 0;
>
> bit_set(U1IER, U1IER_THRE_Interrupt_Enable_BIT);
>
>#endif
>
>#ifdef USART1_RX_INT_MODE
>
> // initialize data queues
>
> bufferInit(&usart1_rx_ringbuf, &usart1_rx_buffer[0],
>sizeof(usart1_rx_buffer));
>
> // enable receiver interrupts
>
> bit_set(U1IER, U1IER_RBR_Interrupt_Enable_BIT);
>
>#endif
>
> break;
>
> case 2: // Radio channel 2
>
> U2LCR = U2LCR_Divisor_Latch_Access_Bit|0x03; /* 8 bit, 1 stop bit,
>no parity, enable DLAB */
>
> U2DLL = divisor & 0xFF;
>
> U2DLM = (divisor > > 8) & 0xFF;
>
> bit_clear(U2LCR, U2LCR_Divisor_Latch_Access_Bit_BIT); /* Disable DLAB
>*/
>
> bit_set(PINSEL9,13); //p4.22
>
> bit_clear(PINSEL9,12);
>
> bit_set(PINSEL9,15); //p4.23
>
> bit_clear(PINSEL9,14);
>
> // disable pull-up/pull down resistors.
>
> bit_set(PINMODE9,13); //p4.22
>
> bit_clear(PINMODE9,12);
>
> bit_set(PINMODE9,15); //p4.23
>
> bit_clear(PINMODE9,14);
>
> // Turn power on to UART 2.
>
> bit_set(PCONP, PCONP_PCUART2_BIT);
>
> U2FCR = U2FCR_FIFO_Enable|U2FCR_Rx_FIFO_Reset;
>
> /* Setup UART RX interrupt */
>
> ctl_set_isr(28, 0, CTL_ISR_TRIGGER_FIXED, uart2ISR, 0);
>
> ctl_unmask_isr(28);
>
>#ifdef USART2_TX_INT_MODE
>
> bufferInit(&usart2_tx_ringbuf, &usart2_tx_buffer[0],
>sizeof(usart2_tx_buffer));
>
> usart2_tx_running = 0;
>
> bit_set(U2IER, U2IER_THRE_Interrupt_Enable_BIT);
>
>#endif
>
>#ifdef USART2_RX_INT_MODE
>
> // initialize data queues
>
> bufferInit(&usart2_rx_ringbuf, &usart2_rx_buffer[0],
>sizeof(usart2_rx_buffer));
>
> // enable receiver interrupts
>
> bit_set(U2IER, U2IER_RBR_Interrupt_Enable_BIT);
>
>#endif
>
> break;
>
> case 3: // BlueTooth channel 3
>
> U3LCR = U3LCR_Divisor_Latch_Access_Bit|0x03; /* 8 bit, 1 stop bit,
>no parity, enable DLAB */
>
> U3DLL = divisor & 0xFF;
>
> U3DLM = (divisor > > 8) & 0xFF;
>
> bit_clear(U3LCR, U3LCR_Divisor_Latch_Access_Bit_BIT); /* Disable DLAB
>*/
>
> bit_set(PINSEL0,1); //p0.0
>
> bit_clear(PINSEL0,0);
>
> bit_set(PINSEL0,3); //p0.1
>
> bit_clear(PINSEL0,2);
>
> // Turn power on to UART 3.
>
> bit_set(PCONP, PCONP_PCUART3_BIT);
>
> U3FCR = U3FCR_FIFO_Enable|U3FCR_Rx_FIFO_Reset;
>
> /* Setup UART RX interrupt */
>
> ctl_set_isr(29, 0, CTL_ISR_TRIGGER_FIXED, uart3ISR, 0);
>
> ctl_unmask_isr(29);
>
>#ifdef USART3_TX_INT_MODE
>
> bufferInit(&usart3_tx_ringbuf, &usart3_tx_buffer[0],
>sizeof(usart3_tx_buffer));
>
> usart3_tx_running = 0;
>
> bit_set(U3IER, U3IER_THRE_Interrupt_Enable_BIT);
>
>#endif
>
>#ifdef USART3_RX_INT_MODE
>
> // initialize data queues
>
> bufferInit(&usart3_rx_ringbuf, &usart3_rx_buffer[0],
>sizeof(usart3_rx_buffer));
>
> // enable receiver interrupts
>
> bit_set(U3IER, U3IER_RBR_Interrupt_Enable_BIT);
>
>#endif
>
> break;
>
> default:
>
> break;
>
> }
>
>}
>
>thanks martijn
>
>
>