I’m currently writing an application based on the example code provided by TK.
All was working like a charm until today. Sometimes, when I add some code concerning the LCD display the MIOS_GLCD_FONT seems to be corrupted. The other fonts provided in .\modules\glcd_font directory works well.
I’ve two section in the void DISPLAY_Tick(void) function:
- display AIN changes
- display DIN changes
Here is my function (the DIN part is still under development):
/////////////////////////////////////////////////////////////////////////////
// This function is called in the mainloop when no temporary message is shown
// on screen. Print the realtime messages here
/////////////////////////////////////////////////////////////////////////////
void DISPLAY_Tick(void) __wparam
{
// do nothing if no update has been requested
if( !app_flags.DISPLAY_UPDATE_REQ )
return;
// clear request
app_flags.DISPLAY_UPDATE_REQ = 0;
switch (last_ain_func) // pot related display update
{
case 1: // current pot = submaster
// print pot name
MIOS_GLCD_FontInit(GLCD_FONT_BIG);
MIOS_GLCD_GCursorSet(16,0);
MIOS_LCD_PrintCString(pot_name[last_ain_pin]);
// print pot value
MIOS_GLCD_GCursorSet(16,4);
MIOS_LCD_PrintBCD3(cur_pot_values[pot_event_map[last_ain_pin][0]]);
// print pot meter value
MIOS_GLCD_FontInit(GLCD_FONT_METER_ICONS_V_BIG);
MIOS_GLCD_GCursorSet(0,0);
MIOS_LCD_PrintChar(pot_meter[cur_pot_values[pot_event_map[last_ain_pin][0]]][0]);
// set LED
if (cur_pot_values[pot_event_map[last_ain_pin][0]]>1)
MIOS_DOUT_PinSet(led_map[pot_event_map[last_ain_pin][0]][0], 0x01);
else
MIOS_DOUT_PinSet(led_map[pot_event_map[last_ain_pin][0]][0], 0x00);
break;
case 2: // current pot = grandmaster
// print pot name
MIOS_GLCD_FontInit(GLCD_FONT_BIG);
MIOS_GLCD_GCursorSet(16,0);
MIOS_LCD_PrintCString(pot_name[last_ain_pin]);
// print pot value
MIOS_GLCD_GCursorSet(16,4);
MIOS_LCD_PrintBCD3(cur_pot_values[pot_event_map[last_ain_pin][0]]);
// print pot meter value
MIOS_GLCD_FontInit(GLCD_FONT_METER_ICONS_V_BIG);
MIOS_GLCD_GCursorSet(0,0);
MIOS_LCD_PrintChar(pot_meter[cur_pot_values[pot_event_map[last_ain_pin][0]]][0]);
// set LED
if (cur_pot_values[pot_event_map[last_ain_pin][0]]>1)
MIOS_DOUT_PinSet(led_map[91][0], 0x01);
else
MIOS_DOUT_PinSet(led_map[91][0], 0x00);
break;
default:
break;
}
last_ain_func=0;
switch (last_din_func) // buton related display update
{
case 1: // current button = flash
// print pot name
MIOS_GLCD_FontInit(GLCD_FONT_BIG);
MIOS_GLCD_GCursorSet(16,0);
MIOS_LCD_PrintCString(but_name[last_din_pin][0]);
break;
default:
break;
}
last_din_func=0;
}
The big arrays (like pot_event_map, …) are defined inside Flash memory:
const unsigned char pot_event_map[64][4] = {
// {real channel, function, MIDI message, MIDI number}
//
// function: 0 - no action
// 1 - submaster
// 2 - grandmaster
//
// MIDI message: 0xb0 - control change
//
// Base Control defined in BL MIDI Control is equal to 70 (-> 70+...)
//
{ 0, 1, 0xb0, 70+ 0}, // Submaster 1
{ 1, 1, 0xb0, 70+ 1}, // Submaster 2
{ 2, 1, 0xb0, 70+ 2}, // Submaster 3
{ 3, 1, 0xb0, 70+ 3}, // Submaster 4
{ 4, 1, 0xb0, 70+ 4}, // Submaster 5
{ 5, 1, 0xb0, 70+ 5}, // Submaster 6
{ 6, 1, 0xb0, 70+ 6}, // Submaster 7
{ 7, 1, 0xb0, 70+ 7}, // Submaster 8
{ 8, 1, 0xb0, 70+ 8}, // Submaster 9
{ 9, 1, 0xb0, 70+ 9}, // Submaster 10
{10, 1, 0xb0, 70+10}, // Submaster 11
{11, 1, 0xb0, 70+11}, // Submaster 12
{12, 1, 0xb0, 70+12}, // Submaster 13
{13, 1, 0xb0, 70+13}, // Submaster 14
{14, 1, 0xb0, 70+14}, // Submaster 15
{15, 1, 0xb0, 70+15}, // Submaster 16
{24, 0, 0xb0, 70+ 0}, //
{25, 0, 0xb0, 70+ 0}, //
{26, 0, 0xb0, 70+ 0}, //
{27, 0, 0xb0, 70+ 0}, //
{28, 0, 0xb0, 70+ 0}, //
{29, 0, 0xb0, 70+ 0}, //
{30, 0, 0xb0, 70+ 0}, //
{31, 0, 0xb0, 70+ 0}, //
{32, 0, 0xb0, 70+ 0}, //
{33, 0, 0xb0, 70+ 0}, //
{34, 0, 0xb0, 70+ 0}, //
{35, 0, 0xb0, 70+ 0}, //
{36, 0, 0xb0, 70+ 0}, //
{37, 0, 0xb0, 70+ 0}, //
{38, 0, 0xb0, 70+ 0}, //
{39, 0, 0xb0, 70+ 0}, //
{16, 1, 0xb0, 70+16}, // Submaster 17
{17, 1, 0xb0, 70+17}, // Submaster 18
{18, 1, 0xb0, 70+18}, // Submaster 19
{19, 1, 0xb0, 70+19}, // Submaster 20
{20, 1, 0xb0, 70+20}, // Submaster 21
{21, 1, 0xb0, 70+21}, // Submaster 22
{22, 1, 0xb0, 70+22}, // Submaster 23
{23, 1, 0xb0, 70+23}, // Submaster 24
{40, 0, 0xb0, 70+ 0}, //
{41, 0, 0xb0, 70+ 0}, //
{42, 0, 0xb0, 70+ 0}, //
{43, 0, 0xb0, 70+ 0}, //
{44, 0, 0xb0, 70+ 0}, //
{45, 0, 0xb0, 70+ 0}, //
{46, 0, 0xb0, 70+ 0}, //
{47, 0, 0xb0, 70+ 0}, //
{48, 0, 0xb0, 70+ 0}, //
{49, 0, 0xb0, 70+ 0}, //
{50, 0, 0xb0, 70+ 0}, //
{51, 0, 0xb0, 70+ 0}, //
{52, 2, 0xb0, 70+24}, // Grand Master
{53, 0, 0xb0, 70+ 0}, // not connected
{54, 0, 0xb0, 70+ 0}, // not connected
{55, 0, 0xb0, 70+ 0}, // not connected
{56, 0, 0xb0, 70+ 0}, // not connected
{57, 0, 0xb0, 70+ 0}, // not connected
{58, 0, 0xb0, 70+ 0}, // not connected
{59, 0, 0xb0, 70+ 0}, // not connected
{60, 0, 0xb0, 70+ 0}, // not connected
{61, 0, 0xb0, 70+ 0}, // not connected
{62, 0, 0xb0, 70+ 0}, // not connected
{63, 0, 0xb0, 70+ 0}, // not connected
};
const unsigned char pot_name[64][8] = {
// 7 caracters + '0' = 8
"Sub. 1", // Submaster 1
"Sub. 2", // Submaster 2
"Sub. 3", // Submaster 3
"Sub. 4", // Submaster 4
"Sub. 5", // Submaster 5
"Sub. 6", // Submaster 6
"Sub. 7", // Submaster 7
"Sub. 8", // Submaster 8
"Sub. 9", // Submaster 9
"Sub. 10", // Submaster 10
"Sub. 11", // Submaster 11
"Sub. 12", // Submaster 12
"Sub. 13", // Submaster 13
"Sub. 14", // Submaster 14
"Sub. 15", // Submaster 15
"Sub. 16", // Submaster 16
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
"Sub. 17", // Submaster 17
"Sub. 18", // Submaster 18
"Sub. 19", // Submaster 19
"Sub. 20", // Submaster 20
"Sub. 21", // Submaster 21
"Sub. 22", // Submaster 22
"Sub. 23", // Submaster 23
"Sub. 24", // Submaster 24
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
" ", //
"GMaster", // Grand Master
" ", // not connected
" ", // not connected
" ", // not connected
" ", // not connected
" ", // not connected
" ", // not connected
" ", // not connected
" ", // not connected
" ", // not connected
" ", // not connected
" ", // not connected
};
const unsigned char but_event_map[96][5] = {
// {real channel, function, MIDI message, MIDI number, MIDI value}
//
// function: 0 - no action
// 1 - flash
// 2 - recall preset
// 3 - read and send all pot state
// 4 - add/kill
//
// MIDI message: 0xb0 - control change
// 0xc0 - program (patch) change
//
// Base Control defined in BL MIDI Control is equal to 70 (-> 70+...)
//
{0, 1, 0xb0, 70+ 0, 0x7f}, // Flash 1
{1, 1, 0xb0, 70+ 1, 0x7f}, // Flash 2
{2, 1, 0xb0, 70+ 2, 0x7f}, // Flash 3
{3, 1, 0xb0, 70+ 3, 0x7f}, // Flash 4
{4, 1, 0xb0, 70+ 4, 0x7f}, // Flash 5
{5, 1, 0xb0, 70+ 5, 0x7f}, // Flash 6
{6, 1, 0xb0, 70+ 6, 0x7f}, // Flash 7
{7, 1, 0xb0, 70+ 7, 0x7f}, // Flash 8
{9, 1, 0xb0, 70+ 9, 0x7f}, // Flash 10
{8, 1, 0xb0, 70+ 8, 0x7f}, // Flash 9
{11, 1, 0xb0, 70+11, 0x7f}, // Flash 12
{10, 1, 0xb0, 70+10, 0x7f}, // Flash 11
{13, 1, 0xb0, 70+13, 0x7f}, // Flash 14
{12, 1, 0xb0, 70+12, 0x7f}, // Flash 13
{15, 1, 0xb0, 70+15, 0x7f}, // Flash 16
{14, 1, 0xb0, 70+14, 0x7f}, // Flash 15
{24, 2, 0xc0, 0, 0}, // Recall preset 1
{25, 2, 0xc0, 1, 0}, // Recall preset 2
{26, 2, 0xc0, 2, 0}, // Recall preset 3
{27, 2, 0xc0, 3, 0}, // Recall preset 4
{28, 2, 0xc0, 4, 0}, // Recall preset 5
{29, 2, 0xc0, 5, 0}, // Recall preset 6
{30, 2, 0xc0, 6, 0}, // Recall preset 7
{31, 2, 0xc0, 7, 0}, // Recall preset 8
{33, 2, 0xc0, 9, 0}, // Recall preset 10
{32, 2, 0xc0, 8, 0}, // Recall preset 9
{35, 2, 0xc0, 11, 0}, // Recall preset 12
{34, 2, 0xc0, 10, 0}, // Recall preset 11
{37, 2, 0xc0, 13, 0}, // Recall preset 14
{36, 2, 0xc0, 12, 0}, // Recall preset 13
{39, 2, 0xc0, 15, 0}, // Recall preset 16
{38, 2, 0xc0, 14, 0}, // Recall preset 15
{17, 1, 0xb0, 70+17, 0x7f}, // Flash 18
{16, 1, 0xb0, 70+16, 0x7f}, // Flash 17
{19, 1, 0xb0, 70+19, 0x7f}, // Flash 20
{18, 1, 0xb0, 70+18, 0x7f}, // Flash 19
{41, 2, 0xc0, 17, 0}, // Recall preset 18
{40, 2, 0xc0, 16, 0}, // Recall preset 17
{43, 2, 0xc0, 19, 0}, // Recall preset 20
{42, 2, 0xc0, 18, 0}, // Recall preset 19
{50, 0, 0xb0, 0, 0}, //
{49, 0, 0xb0, 0, 0}, //
{52, 0, 0xb0, 0, 0}, //
{51, 0, 0xb0, 0, 0}, //
{58, 0, 0xb0, 0, 0}, //
{59, 0, 0xb0, 0, 0}, //
{60, 0, 0xb0, 0, 0}, //
{57, 4, 0xb0, 0, 0}, // Add / kill (solo)
{65, 0, 0xb0, 0, 0}, //
{64, 0, 0xb0, 0, 0}, //
{67, 0, 0xb0, 0, 0}, //
{66, 0, 0xb0, 0, 0}, //
{69, 0, 0xb0, 0, 0}, // not connected
{48, 3, 0xb0, 0, 0}, // Read and send all pot state
{70, 0, 0xb0, 0, 0}, // not connected
{71, 0, 0xb0, 0, 0}, // not connected
{72, 0, 0xb0, 0, 0}, // not connected
{73, 0, 0xb0, 0, 0}, // not connected
{74, 0, 0xb0, 0, 0}, // not connected
{75, 0, 0xb0, 0, 0}, // not connected
{76, 0, 0xb0, 0, 0}, // not connected
{77, 0, 0xb0, 0, 0}, // not connected
{78, 0, 0xb0, 0, 0}, // not connected
{79, 0, 0xb0, 0, 0}, // not connected
{21, 1, 0xb0, 70+21, 0x7f}, // Flash 22
{20, 1, 0xb0, 70+20, 0x7f}, // Flash 21
{23, 1, 0xb0, 70+23, 0x7f}, // Flash 24
{22, 1, 0xb0, 70+22, 0x7f}, // Flash 23
{45, 2, 0xc0, 21, 0}, // Recall preset 22
{44, 2, 0xc0, 20, 0}, // Recall preset 21
{47, 2, 0xc0, 23, 0}, // Recall preset 24
{46, 2, 0xc0, 22, 0}, // Recall preset 23
{54, 0, 0xb0, 0, 0}, //
{53, 0, 0xb0, 0, 0}, //
{56, 0, 0xb0, 0, 0}, //
{55, 0, 0xb0, 0, 0}, //
{62, 0, 0xb0, 0, 0}, //
{61, 0, 0xb0, 0, 0}, //
{68, 0, 0xb0, 0, 0}, //
{63, 0, 0xb0, 0, 0}, //
{80, 0, 0xb0, 0, 0}, // not connected
{81, 0, 0xb0, 0, 0}, // not connected
{82, 0, 0xb0, 0, 0}, // not connected
{83, 0, 0xb0, 0, 0}, // not connected
{84, 0, 0xb0, 0, 0}, // not connected
{85, 0, 0xb0, 0, 0}, // not connected
{86, 0, 0xb0, 0, 0}, // not connected
{87, 0, 0xb0, 0, 0}, // not connected
{88, 0, 0xb0, 0, 0}, // not connected
{89, 0, 0xb0, 0, 0}, // not connected
{90, 0, 0xb0, 0, 0}, // not connected
{91, 0, 0xb0, 0, 0}, // not connected
{92, 0, 0xb0, 0, 0}, // not connected
{93, 0, 0xb0, 0, 0}, // not connected
{94, 0, 0xb0, 0, 0}, // not connected
{95, 0, 0xb0, 0, 0}, // not connected
};
const unsigned char but_name[96][2][9] = {
// 2 rows of
// 8 caracters + '0' = 9
{"Sub. 1 "," "}, // Flash 1
{"Sub. 2 "," "}, // Flash 2
{"Sub. 3 "," "}, // Flash 3
{"Sub. 4 "," "}, // Flash 4
{"Sub. 5 "," "}, // Flash 5
{"Sub. 6 "," "}, // Flash 6
{"Sub. 7 "," "}, // Flash 7
{"Sub. 8 "," "}, // Flash 8
{"Sub. 10 "," "}, // Flash 10
{"Sub. 9 "," "}, // Flash 9
{"Sub. 12 "," "}, // Flash 12
{"Sub. 11 "," "}, // Flash 11
{"Sub. 14 "," "}, // Flash 14
{"Sub. 13 "," "}, // Flash 13
{"Sub. 16 "," "}, // Flash 16
{"Sub. 15 "," "}, // Flash 15
{"Recall ","Preset 1"}, // Recall preset 1
{"Recall ","Preset 2"}, // Recall preset 2
{"Recall ","Preset 3"}, // Recall preset 3
{"Recall ","Preset 4"}, // Recall preset 4
{"Recall ","Preset 5"}, // Recall preset 5
{"Recall ","Preset 6"}, // Recall preset 6
{"Recall ","Preset 7"}, // Recall preset 7
{"Recall ","Preset 8"}, // Recall preset 8
{"Recall ","Preset10"}, // Recall preset 10
{"Recall ","Preset 9"}, // Recall preset 9
{"Recall ","Preset12"}, // Recall preset 12
{"Recall ","Preset11"}, // Recall preset 11
{"Recall ","Preset14"}, // Recall preset 14
{"Recall ","Preset13"}, // Recall preset 13
{"Recall ","Preset16"}, // Recall preset 16
{"Recall ","Preset15"}, // Recall preset 15
{"Sub. 18 "," "}, // Flash 18
{"Sub. 17 "," "}, // Flash 17
{"Sub. 20 "," "}, // Flash 20
{"Sub. 19 "," "}, // Flash 19
{"Recall ","Preset18"}, // Recall preset 18
{"Recall ","Preset17"}, // Recall preset 17
{"Recall ","Preset20"}, // Recall preset 20
{"Recall ","Preset19"}, // Recall preset 19
{" "," "}, //
{" "," "}, //
{" "," "}, //
{" "," "}, //
{" "," "}, //
{" "," "}, //
{" "," "}, //
{"Solo ON ","Solo OFF"}, // Add / kill (solo)
{" "," "}, //
{" "," "}, //
{" "," "}, //
{" "," "}, //
{" "," "}, // not connected
{" "," "}, // Read and send all pot state
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{"Sub. 22 "," "}, // Flash 22
{"Sub. 21 "," "}, // Flash 21
{"Sub. 24 "," "}, // Flash 24
{"Sub. 23 "," "}, // Flash 23
{"Recall ","Preset22"}, // Recall preset 22
{"Recall ","Preset21"}, // Recall preset 21
{"Recall ","Preset24"}, // Recall preset 24
{"Recall ","Preset23"}, // Recall preset 23
{" "," "}, //
{" "," "}, //
{" "," "}, //
{" "," "}, //
{" "," "}, //
{" "," "}, //
{" "," "}, //
{" "," "}, //
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
{" "," "}, // not connected
};
When I disable the switch(last_ain_func) or switch(last_ain_func) there isn’t any problem. But when I enable both it works but it just like if the MIOS_GLCD_FONT was corrupted: the MIOS is rebooting and the © T.K. aren’t visible (blank display or erratic characters). All the other parts are still working (other fonts, AIN, DIN, DOUT, MIDI send, …). I have to reload the MIOS itself in order to get back the display.
What could be the problem? Too much code inside this function? (I’ve tried to put this portion of code inside the void Tick(void) function: same problem). I’m very lost inside this problem. Any idea is welcome.
EDIT
This problem is not only due to the void DISPLAY_Tick(void) function. When I just add an if statement in the void DIN_NotifyToggle(unsigned char pin, unsigned char pin_value) function it produces the same problem.
Do you think my code is too big and overwrite the memory area used for the MIOS_GLCD_FONT? I’m using a PIC18F452. How can I verify this?
Best regards,
nsunier