cancel
Showing results for 
Search instead for 
Did you mean: 

Put interrupt in RAM or pre cache

Nickelgrass
Senior

Hello,

I am using GCC and eclipse CDT. I need to execute an external interrupt very fast (every 4µs). There is not a lot to do in there but I use about 2.5µs of time in the interrupthandler. I tryied to put the handler in to ram wich gave me the relocation truncated to fit: R_ARM_THM_CALL against symbol error.

I put the handler into the data section with __attribute__ ((section(".data"))) . The reset handler copies the data section to ram. In the linker the data section is defined with

  .data : 

  {

   _data = .;

   *(.data)    /* Data memory */

   _edata = .;

  } >ram AT > rom

Now my question is what could be wrong. The STM32F103C8 has 20K of RAM. That should be more than enough plus all the variables.

Alternative would be to pre cache the interrupt code and keep it in code. Is that possible?

When I look at the code execution by toggling a pin it seems the interrupt fires about 900ns after the interrupt is triggered. So with my execution of 2.5µs it leaves me a margin of narrowly 500ns. I would like to squeeze in some litte bit more that I can not process outside of the interrupt. Thus I need to optimize the speed.

I have never attempted to do this and could not find any complete examples.

Kind regards

1 ACCEPTED SOLUTION

Accepted Solutions
Nickelgrass
Senior

Ok, figured it out.

For anyone interested:

I defined an own section withing data:

  .data : 

  {

   _data = .;

   *(.data)    /* Data memory */

   . = ALIGN(4);

*(.rfunc)

   _edata = .;

  } >ram AT > rom

And put the interrupt into rfunc. Performance is increased. Exectution time is down to 1.875µs in contrast to 2.416µs previously! Although the latency has not changed.

View solution in original post

1 REPLY 1
Nickelgrass
Senior

Ok, figured it out.

For anyone interested:

I defined an own section withing data:

  .data : 

  {

   _data = .;

   *(.data)    /* Data memory */

   . = ALIGN(4);

*(.rfunc)

   _edata = .;

  } >ram AT > rom

And put the interrupt into rfunc. Performance is increased. Exectution time is down to 1.875µs in contrast to 2.416µs previously! Although the latency has not changed.