We are trying to make a uavcan adapter for another microprocessor.
We have used theimar vector control as a guide to getting uavcan up and running.
Currently we have uavcan working and can see can messages using the uavcan gui tool.
We are now trying to get a serial port running on the STM32 so it can communicate with another micro. I have successfully got polled comms between the two but am getting hardfaults whenever I enable the usart irq.
There seems to be two different methods for attaching IRQ's , irq_attach or using the vector table.
I have added my usart IRQ to the vector table and when debugging it shows up correctly in app_vectors[]. The interrupt is never entered and when stopped shows
"signal handler called>() at 0xfffffff9" and is stuck at invalid location.
This occurs after usart irq enabled or when attempting to tx a byte on usart.
Looks like it might be a hard fault.
I have checked everything I can but can't find the fault.
Is there any special requirements to adding USART1 interrupts?
(Note clocks and gpio enabled prior and usart is working in polled mode, following is called in hals2740vc_1_0.cpp)
Code goes somehting like this
//setup
putreg32( getreg32(STM32_USART1_CR1) | USART_CR1_UE |
USART_CR1_RE | USART_CR1_TE|USART_CR1_RXNEIE|USART_CR1_TXEIE,
STM32_USART1_CR1 );
putreg32(USART_BRR,STM32_USART1_BRR );
up_prioritize_irq(STM32_IRQ_USART1, NVIC_SYSH_PRIORITY_DEFAULT);
up_enable_irq(STM32_IRQ_USART1);
// interrupt sample
extern "C" void stm32_usart1(void)
{
uint32_t ISR = getreg32(STM32_USART1_ISR);
if((ISR&USART_ISR_RXNE) != 0)
{
uint8_t c = 0xFF & getreg32(STM32_USART1_RDR); // read data
}
if((ISR&USART_ISR_TXE)!= 0) //USART_ISR_TC
{
uint8_t c= 'r';
putreg32(c&0xff,STM32_USART1_TDR); //transfer data to DR register
}
}