anonymous wrote on Saturday, February 27, 2010:
Well I haven’t seen a follow up yet, so let me expand my issue.
The main problem that I am having with the LPC1768 is that you cannot have a fully interrupt driven serial driver because the Transmit ISR only triggers on a FIFO transition to empty instead of generating interrupts while empty. So while IDEALLY I would like to do this:
My code would call this function to place characters into the serial buffer:
signed portBASE_TYPE serial_putChar(signed portCHAR ch, portTickType xBlockTime )){
signed portBASE_TYPE xReturn = pdFAIL;
xReturn = xQueueSend( TxQueue, &ch, xBlockTime );
UART1->IER |= UART_IER_THREINT_EN;
return xReturn;
}
And this would be the serial interrupt handler:
void serialISR(){
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
portCHAR cChar;
if(UART1->IIR & UART_IIR_INTID_THRE){
if( xQueueReceiveFromISR( TxQueue, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE ){
UART1->THR = cChar;
}
else{
UART1->IER &= ~UART_IER_THREINT_EN;
}
}
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
}
This part doesn’t work like that.
So I am working to have a task load the THR transmit register for me. This is what I have so far (rough outline):
My main function call would be
signed portBASE_TYPE serial_putChar(signed portCHAR cOutChar, portTickType xBlockTime )
{
signed portBASE_TYPE xReturn = pdFAIL;
if( xQueueSend( xCharsForTx, &cOutChar, xBlockTime ) == pdPASS ){
xReturn = pdPASS;
}
return xReturn;
}
The interrupt handler:
void serialISR(void)
{
portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE;
portCHAR cChar;
if(UART1->IIR & UART_IIR_INTID_THRE){
{
xSemaphoreGiveFromISR(xSendSemaphore, &xHigherPriorityTaskWoken);
}
portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );
}
And my task to load characters into the THR register would be
void xUARTsendTask(void *pvParameter)
{
uint8_t sendChar;
vSemaphoreCreateBinary(xSendSemaphore);
xSemaphoreTake(xSendSemaphore, 0);
for( ;; ){
xQueueReceive(xCharsForTx, &sendChar, portMAX_DELAY);
UART1->THR = sendChar;
xSemaphoreTake(xSendSemaphore, portMAX_DELAY);
}
}
The problem I have with this is that it halts have transmitting 2 characters. So what I am looking for is some ideas on making this work.