2009-05-17 05:26 AM
CAN TX interrupt
2011-05-17 04:11 AM
Hello every body,
I have a trouble in getting CAN transmission interrupt to work. How do i activate the interrupt? I use this while initialising the NVIC: NVIC_InitStructure.NVIC_IRQChannel = USB_HP_CAN_TX_IRQChannel; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 192; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); I am using FREERTOS so i need the priority to be higher than 191 in order to make some features work. And each time i want to send data i put it in a queu and then activate the TX interrupt as follow void CAN_Write(char* c) { char* d=c; xSemaphoreTake(xCANTXSemaphore,( portTickType ) portMAX_DELAY); while(*d!=0) { xQueueSend(xCANQueuTX, d++,( portTickType ) portMAX_DELAY); } CAN_ITConfig(CAN_IT_TME, ENABLE);//on active l'interruption d'ecriture xSemaphoreGive(xCANTXSemaphore); } Then in the IRQ i do this: void ISR_CANTX() { CanTxMsg TxMessage; portBASE_TYPE xHigherPriorityTaskWoken=pdFALSE ; TxMessage.StdId=0x11; TxMessage.RTR=CAN_RTR_DATA; TxMessage.IDE=CAN_ID_STD; TxMessage.DLC=2; //Si il y a encore quoi envoyer on envoi if(xQueueReceiveFromISR( xRS232QueuTX, &( TxMessage.Data[0] ),&xHigherPriorityTaskWoken)) { CAN_Transmit(&TxMessage); } else//sinon on desactive cette interruption { CAN_ITConfig(CAN_IT_TME,DISABLE); } CAN_ClearITPendingBit(CAN_IT_TME); portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); } I chack the queu, if there is something to send i send it else i disactivate the interrupt. I have initialised the interrupts vector to make this routine the one called when an interrupt occurs on USB_HP_CAN_TX_IRQChannel. Did i miss something, and am i right to use this IRQChannel and this interrupt: CAN_ITConfig(CAN_IT_TME, ENABLE); ? Thanks [ This message was edited by: aloui.seifeddine on 12-05-2009 22:59 ]2011-05-17 04:12 AM
In fact, i think there is a Bug in the STM32. It is written that TME is Transmit Mailbox Empty, but i found that this interrupt occurs when the CAN TX transmission is done!!!
2011-05-17 04:12 AM
Hi Seif,
The TME interrupt is connected to 3 Flags (RQCP2,RQCP1,RQCP0) the description of RQCPx flag is : Request Completed for Mailbox x , This bit is set by hardware to signal that the last request for mailbox x has been completed. The request could be a transmit or an abort request. This bit is cleared by software writing 1. The TME interrupt is an indicator that the Transmission is done (or aborded). ;) Amin