Microblaze 2nd timer interrupt

Sam Price thesamprice at gmail.com
Sun Nov 6 04:52:31 UTC 2022


I pushed my changes to rtems source
https://github.com/RTEMS/rtems/compare/master...thesamprice:rtems:timer_debug

and setup a hello world an example project to test with
https://github.com/thesamprice/rtems_mb_timer/blob/main/hello.c

However im getting the following error.
rtems_mb_timer/hello.c:8:10: fatal error: bsp/timer.h: No such file or directory
    8 | #include <bsp/timer.h>
      |          ^~~~~~~~~~~~~

Is the correct approach to just put all bsp specific calls in bsp.h?


On Sat, Nov 5, 2022 at 10:04 PM Sam Price <thesamprice at gmail.com> wrote:
>
> The current microblaze design only has a single timer.
>
> I want to use the 2nd timer on the microblaze to run some low level tasks.
>
> Wondering if someone could see if i'm on the right track.
>
>
> Regarding the timer from the Xilinx api api
>
> """The interrupt service routine reads the timer control/status
> registers to determine the source of the interrupt."""
>
> Also there is a interrupt controller on microblaze that has a single
> jump register.
>
>
> So the underlying logic is interrupt occurs, 32bit interrupt register
> is checked for what bits are set determining what interrupts have
> occured.
>
>
> if bit 0 is set then it is a clock interrupt.
>
>
> Then 2 clock register need checked for what timer caused the interrupt.
>
>
> Current RTEMS implementation only uses 1 of the timers.
>
>
>
>
>
> I added static ISR callbacks for the system and user callback at the
> top of the mb clock.c file.
>
> static rtems_interrupt_handler mblaze_clock_isr = 0x0;
>
> static rtems_interrupt_handler mblaze_user_isr = 0x0;
>
>
>
> I added a callback that checks both registers and calls the
> appropriate callback.
>
>
>
> static void microblaze_clock_handler( void * data){
>
>   volatile Microblaze_Timer *timer = _Microblaze_Timer;
>
>   if ( ( timer->tcsr0 & MICROBLAZE_TIMER_TCSR0_T0INT ) == 0 )
>
>   {
>
>     if(mblaze_clock_isr != 0x0){
>
>       mblaze_clock_isr(data);
>
>     }
>
>   }
>
>   if ( ( timer->tcsr1 & MICROBLAZE_TIMER_TCSR0_T0INT ) == 0 )
>
>   {
>
>     if(mblaze_user_isr != 0x0){
>
>       mblaze_user_isr(data);
>
>       /* Clear the interrupt */
>
>       timer->tcsr1 |= MICROBLAZE_TIMER_TCSR0_T0INT;
>
>     }
>
>   }
>
> }
>
>
>
>
>
> I updated the ISR register to store the system clock, and replace the
> isr callback with mine.
>
>
>
> static void microblaze_clock_handler_install( rtems_interrupt_handler isr )
>
> {
>
>   rtems_status_code sc = RTEMS_SUCCESSFUL;
>
>   mblaze_clock_isr = isr; <- Store the system ISR
>
>   sc = rtems_interrupt_handler_install(
>
>     0,
>
>     "Clock",
>
>     RTEMS_INTERRUPT_UNIQUE,
>
>     microblaze_clock_handler, <- Changed from ISR to my new handler.
>
>     NULL
>
>   );
>
>
>
>   if ( sc != RTEMS_SUCCESSFUL ) {
>
>     bsp_fatal( MICROBLAZE_FATAL_CLOCK_IRQ_INSTALL );
>
>   }
>
> }
>
>
>
> To the microblaze bsp.h
>
>
> im adding my callback functions to register the users clock function.
>
> void microblaze_user_clock_handler_install(rtems_interrupt_handler isr);
>
>
> And the appropriate non static function to the mb clock.c file
>
> void microblaze_user_clock_handler_install(rtems_interrupt_handler isr){
> mblaze_user_isr = isr;
> }
>
> Anyhow about to compile and see if it works.



-- 
Sincerely,

Sam Price


More information about the devel mailing list