Adding peripheral interrupts, hardfaulting?

578 views
Skip to first unread message

Kent Martin

unread,
Aug 9, 2017, 2:46:14 AM8/9/17
to UAVCAN
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
}
}

Pavel Kirienko

unread,
Aug 9, 2017, 5:51:05 AM8/9/17
to Kent Martin, UAVCAN
Hi Kent,

This seems like a general programming question not directly related to UAVCAN. You should have better luck asking it either to Ben Dyer, the developer of Thiemar ESC, or at the NuttX mailing list.

You may also want to check out the sources of Zubax Babel, which is an open source USB-CAN and UART-CAN adapter: https://github.com/Zubax/zubax_babel. It is based on ChibiOS rather than NuttX.

Pavel.

--
You received this message because you are subscribed to the Google Groups "UAVCAN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uavcan+unsubscribe@googlegroups.com.
To post to this group, send email to uav...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/uavcan/fb17897d-4907-468d-a1e8-8fdfc35eddef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kent Martin

unread,
Aug 13, 2017, 8:27:00 PM8/13/17
to UAVCAN, kentma...@gmail.com
Looking further there are two sets of vector tables in the code. It's hard to decipher who this is intended to be used.
In stm32_vectors.s there is section _vectors:
where system vectors are pointed  exception_common which calls up_doirq, (maybe depending on defines) which then calls functions from a another vector table g_irqvector.
However since CONFIG_STM32_NOEXT_VECTORS is defined no peripheral vectors will be included in _vectors:.

The other set of vectors resides at app_vectors defined in app_vectors.c 
Weakly defined vectors will be overridden and appear in this table.
However the vector table address only appears to be written in the bootloader main.c application_run where NVIC_VECTAB is written to 0x8002000.
However when I debug the main code the vector table address is not at 0x8002000. 
If I manually write the vector table address to 0x8002000 at the start of the main application it will jump to the default_handler which loops forever.
I'm assuming a system interrupt has occurred and by changing the vector address, I have subverted the intended path for vectors.
My question then is where does the vector table get written to other than 0x8002000 and exactly whic vector table is supposed to be used and how do I add a peripheral interrupr to it? Noe also that the original code was using ADC12 peripheral interrupt and I saw no place where he had added the intterupt code other than in the app_vector table which never gets used since vector table address is not at 0x8002000.

Thanks.

 

Pavel Kirienko

unread,
Aug 14, 2017, 7:50:04 AM8/14/17
to Kent Martin, UAVCAN
Kent,

I'm afraid you won't find help with this question on this list, it is off-topic. As I said, you should try Zubax Babel if you want a solution that has a working technical support.

Pavel.

--
You received this message because you are subscribed to the Google Groups "UAVCAN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uavcan+unsubscribe@googlegroups.com.
To post to this group, send email to uav...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages