change serial interrupt routine

Post here first, or if you can't find a relevant section!
Post Reply
octavio
Posts: 44
Joined: Sat Apr 15, 2017 6:41 pm
Location: barcelona
Contact:

change serial interrupt routine

Post by octavio » Thu Oct 05, 2017 6:34 pm

Hello,how can i declare a interrupt routine for USART3 (Serial2).

victor_pv
Posts: 1681
Joined: Mon Apr 27, 2015 12:12 pm

Re: change serial interrupt routine

Post by victor_pv » Thu Oct 05, 2017 8:02 pm

Did you see one in the core? if there is one, it's probably weak. Otherwise there may be an attachInterrupt method or something like it to piggyback yours to the core one.

That's how the DMA channels work as an example. Rather than declare an ISR, you just use the attach function to pass your ISR pointer to the core, and it will be called from the core ISR.

octavio
Posts: 44
Joined: Sat Apr 15, 2017 6:41 pm
Location: barcelona
Contact:

Re: change serial interrupt routine

Post by octavio » Thu Oct 05, 2017 9:19 pm

" there may be an attachInterrupt method"
I did not found it.
Last edited by octavio on Thu Oct 05, 2017 9:22 pm, edited 1 time in total.

victor_pv
Posts: 1681
Joined: Mon Apr 27, 2015 12:12 pm

Re: change serial interrupt routine

Post by victor_pv » Thu Oct 05, 2017 9:21 pm

octavio wrote:
Thu Oct 05, 2017 9:19 pm
" there may be an attachInterrupt method"
I did not found it.
Did you see if the core ISR is declared weak? most are.

octavio
Posts: 44
Joined: Sat Apr 15, 2017 6:41 pm
Location: barcelona
Contact:

Re: change serial interrupt routine

Post by octavio » Thu Oct 05, 2017 9:26 pm

https://github.com/rogerclarkmelbourne/ ... usart_f1.c

Code: Select all

void __irq_usart2(void)
Not sure if this is the code,but it seems is declared the normal way.

octavio
Posts: 44
Joined: Sat Apr 15, 2017 6:41 pm
Location: barcelona
Contact:

Re: change serial interrupt routine

Post by octavio » Thu Oct 05, 2017 9:29 pm

Code: Select all

void usart_init(usart_dev *dev) {
    rb_init(dev->rb, USART_RX_BUF_SIZE, dev->rx_buf);
    rb_init(dev->wb, USART_TX_BUF_SIZE, dev->tx_buf);
    rcc_clk_enable(dev->clk_id);
    nvic_irq_enable(dev->irq_num);
}
it seems that the vector is hardcoded.

victor_pv
Posts: 1681
Joined: Mon Apr 27, 2015 12:12 pm

Re: change serial interrupt routine

Post by victor_pv » Thu Oct 05, 2017 9:48 pm

Seems like it, and the core handler, here, doesn't show any provision to call a user function either:
https://github.com/rogerclarkmelbourne/ ... vate.h#L40

You can change the vector ni one of this files (I forgot how they work with each other). Also I believe there was a thread about this some months back:
https://github.com/rogerclarkmelbourne/ ... nce/isrs.S
https://github.com/rogerclarkmelbourne/ ... or_table.S
https://github.com/rogerclarkmelbourne/ ... ymbols.inc

This was the thread:
viewtopic.php?f=3&t=1816&hilit=usart+isr+weak

octavio
Posts: 44
Joined: Sat Apr 15, 2017 6:41 pm
Location: barcelona
Contact:

Re: change serial interrupt routine

Post by octavio » Sat Oct 07, 2017 7:54 pm

Thanks,i did the same as Riva and it seems to work.

Post Reply