I wrote a small driver for a display based on an ili9488. Everything is running on a dsPIC33EV256M002.
I gave priorities to interrupts and any one of their handlers, up to level 3 (low frequencies interrupts), may have to write something to the display, in addition to the main loop running at IPL 0.
Drivers for i2c and uart never access the display and I gave the corresponding interrupts a priority of 5.
I don't want to queue the requests to write to the display because this could take to much RAM. As some sections of the ili driver code cannot be interrupted (they can, but not to do other things with the ili9488 chip), I decided to "artificially" raise the IPL to 4 when I am running those sections of code. Can this cause any problem ? Thanks for any advice.
static uint16_t IPLbits;
static void LCD_SetIPL ()
{
__builtin_disable_interrupts();
IPLbits = SR & 0b0000000011100000;
SR = (SR & 0b1111111100011111) | 0b0000000010000000; // 0b100 = 4
__builtin_enable_interrupts();
}
static void LCD_RestoreIPL ()
{
__builtin_disable_interrupts();
SR = (SR & 0b1111111100011111) | IPLbits;
__builtin_enable_interrupts();
}