01-05-2021, 03:01 PM
Hi there
I have a question about the interrupt handling of a PULPissimo with a RI5CY core.
The thing is, I am able to generate timer interrupts as long as I use the rt_api.h file and the functions, that are implemented there. Everything works fine then.
It would be very nice now, if it is possible to write my own functions. So I took the PULPissimo datasheet and started to set the right registers.
For testing reasons I want to generate interrupts from one of the APB Timers, jump into a callback function and toggle an LED. But that does not happen.
The program jumps once into the callback function but after never again. If I debug and set a breakpoint in the callback function, this breakpoint will never be reached twice.
Also tested the timer if everything works there as expected and it looks like the timer is fine. And in the interrupt pending register the correct bit is set but it does not jump.
My question now is, is there something else, maybe an other register or something, that I have to clear or set? Maybe I did not understand the interrupt handling right?
Would be nice if someone can help me here.
If it helps to understand my problem, here is the little test application I would like to run. The functions, that I wrote do not much more than setting the right bits of the right registers.
Thank you very much and wish you all a nice evening
I have a question about the interrupt handling of a PULPissimo with a RI5CY core.
The thing is, I am able to generate timer interrupts as long as I use the rt_api.h file and the functions, that are implemented there. Everything works fine then.
It would be very nice now, if it is possible to write my own functions. So I took the PULPissimo datasheet and started to set the right registers.
For testing reasons I want to generate interrupts from one of the APB Timers, jump into a callback function and toggle an LED. But that does not happen.
The program jumps once into the callback function but after never again. If I debug and set a breakpoint in the callback function, this breakpoint will never be reached twice.
Also tested the timer if everything works there as expected and it looks like the timer is fine. And in the interrupt pending register the correct bit is set but it does not jump.
My question now is, is there something else, maybe an other register or something, that I have to clear or set? Maybe I did not understand the interrupt handling right?
Would be nice if someone can help me here.
Code:
/*=============================================================================================================================
* @file main.c
* @author
* @brief This is a testing program for the PULPissimo microcontroller that is implemented on a FPGA NEXYS4 board.
* There is a hardware abstraction layer, that was created for that board. This program helps to find out
* if everything is working as expected.
* @date 2021-01-02
* @version v1.0
============================================================================================================================*/
//#include <stdio.h>
#include <stdint.h>
#include "HAL/hal_gpio.h"
#include "HAL/HAL_Defines.h"
#include "HAL/hal_timer.h"
#include "HAL/hal_interrupt.h"
#include "HAL/pulpissimo.h"
//#include <rt/rt_api.h>
//int __rt_fpga_fc_frequency = 20000000;
//int __rt_fpga_periph_frequency = 10000000;
//unsigned int __rt_iodev_uart_baudrate = 115200;
/**************************************************
* @note -
* @brief Callback function for timer interrupt.
* @param -
* @return -
************************************************/
void callback_3(void)
{
INT_MASK_R &= ~0x400; //disable timer interrupt line
TIM_CFG_LO &= ~0x4; //diasable timer interrupts
INT_ACK_R &= ~0x400; //clear interrupt ACK flag
hal_gpio_toggle(LED0); //toggle LED0
INT_CTR_R &= ~0x400; //clear pending interrupt flag
INT_MASK_R |= 0x400; //enable timer interrupt line
TIM_CFG_LO |= 0x4; //enable timer interrupts
}
int main()
{
hal_gpio_init(LED0, OUTPUT); //init LED0
hal_gpio_init(LED1, OUTPUT); //init LED1
hal_gpio_write(LED0, LOW); //turn off LED0
hal_gpio_write(LED1, LOW); //turn off LED1
INT_MASK_R &= ~0xFFFFFFFF; //disable all interrupt lines
INT_CTR_R &= ~0xFFFFFFFF; //clear all pending interrupts
TIM_CNT_LO &= ~0xFFFFFFFF; //set timer count register to zero
hal_interrupt_set_handler(10, callback_3); //register callback function for timer interrupt
hal_timer1_init(0, RTC_32KHZ, CONTINUE,CMP_RST); //init timer
hal_timer1_set_cmp(0xFFFF); //set timer compare register value
hal_timer1_en_int(1); //enable timer interrupts
hal_timer1_start(); //start timer
while(1)
{
//checks if timer is running as expected
if(TIM_CNT_LO >= 0xFFF)
hal_gpio_write(LED1, 1);
else
hal_gpio_write(LED1, 0);
}
return 0;
}
If it helps to understand my problem, here is the little test application I would like to run. The functions, that I wrote do not much more than setting the right bits of the right registers.
Thank you very much and wish you all a nice evening