mikew 0 Posted January 28, 2008 Report Share Posted January 28, 2008 I recently changed to BoostC Version 6.84, mainly to see if it would correct the flash_loadbuffer problem. Now I find that a program that was working perfectly well under the previous version fails due to the switch-case not being actioned. I have debugged as far as determining that all the desired switch values are ignored and the program falls into the default case. (The values are to be taken from a buffer and range from 0xA7 to 0xAE ) OR.. What am I doing wrong? (is 6.84 not really out of beta?) Regards. Quote Link to post Share on other sites
Dave 0 Posted January 28, 2008 Report Share Posted January 28, 2008 mikew I recently changed to BoostC Version 6.84, mainly to see if it would correct the flash_loadbuffer problem. Now I find that a program that was working perfectly well under the previous version fails due to the switch-case not being actioned. I have debugged as far as determining that all the desired switch values are ignored and the program falls into the default case. (The values are to be taken from a buffer and range from 0xA7 to 0xAE ) OR.. What am I doing wrong? (is 6.84 not really out of beta?) Regards. Please provide a short example of exactly what you believe is failing, or is difficult for us to help. Regards Dave Quote Link to post Share on other sites
mikew 0 Posted January 29, 2008 Author Report Share Posted January 29, 2008 mikewI recently changed to BoostC Version 6.84, mainly to see if it would correct the flash_loadbuffer problem. Now I find that a program that was working perfectly well under the previous version fails due to the switch-case not being actioned. I have debugged as far as determining that all the desired switch values are ignored and the program falls into the default case. (The values are to be taken from a buffer and range from 0xA7 to 0xAE ) OR.. What am I doing wrong? (is 6.84 not really out of beta?) Regards. Please provide a short example of exactly what you believe is failing, or is difficult for us to help. Regards Dave Quote Link to post Share on other sites
mikew 0 Posted January 29, 2008 Author Report Share Posted January 29, 2008 do { if(!test_bit(porte,1)) //byte received in USB FIFO buffer... { receive_packet(); //collect packets into buffer switch(buffer[1]) { case 0xA7: //set time { day=buffer[2]; hours=buffer[3]; minutes=buffer[4]; break; } case 0xA8: //set hw times { ON_time_hours=buffer[2]; ON_time_mins=buffer[3]; OFF_time_hours=buffer[4]; OFF_time_mins=buffer[5]; break; } case 0xA9: //boiler temp. { Boiler_temp=buffer[2]; break; } case 0xAA: //hysteresis { hysteresis=buffer[2]; break; } case 0xAB: //read 4 temps. { temp1=ADC_Read(0); delay_ms(2); send(temp1); temp1=ADC_Read(1); send(temp1); delay_ms(2); temp1=ADC_Read(2); send(temp1); delay_ms(2); temp1=ADC_Read(3); send(temp1); delay_ms(2); break; } case 0xAC: //set HW return temp { HW_return = buffer[2]; break; } case 0xAD: //set CH return temp { CH_return = buffer[2]; break; } case 0xAE: { for (n=0;n<255;n++) { send(eeprom_read(n)); delay_us(10); } break; } default: { lcd_goto(40); lcd_puts("ERR "); sprintf(message, "%X", buffer[1]); lcd_puts(message); delay_ms(100); } } } Quote Link to post Share on other sites
mikew 0 Posted January 29, 2008 Author Report Share Posted January 29, 2008 The following fragment is copied from the source. This compiles and works as expected in 6.70 and compiles without error but does not work under 6.84. Displaying the contents of buffer[1] to an LCD (another part of the same code) shows that it contains the sent values, eg 0xA7 etc., but they are all ignored and default is always executed. (BTW, although the comms is via USB from a PC using virtual comm ports, all that is handled by a FTDI FT245 chip, not the PIC) I have reverted to 6.7 and all is now OK, so no urgency on my part!! Over to you.... do { if(!test_bit(porte,1)) //byte received in USB FIFO buffer... { receive_packet(); //collect packets into buffer switch(buffer[1]) { case 0xA7: //set time { day=buffer[2]; hours=buffer[3]; minutes=buffer[4]; break; } case 0xA8: //set hw times { ON_time_hours=buffer[2]; ON_time_mins=buffer[3]; OFF_time_hours=buffer[4]; OFF_time_mins=buffer[5]; break; } case 0xA9: //boiler temp. { Boiler_temp=buffer[2]; break; } case 0xAA: //hysteresis { hysteresis=buffer[2]; break; } case 0xAB: //read 4 temps. { temp1=ADC_Read(0); delay_ms(2); send(temp1); temp1=ADC_Read(1); send(temp1); delay_ms(2); temp1=ADC_Read(2); send(temp1); delay_ms(2); temp1=ADC_Read(3); send(temp1); delay_ms(2); break; } case 0xAC: //set HW return temp { HW_return = buffer[2]; break; } case 0xAD: //set CH return temp { CH_return = buffer[2]; break; } case 0xAE: { for (n=0;n<255;n++) { send(eeprom_read(n)); delay_us(10); } break; } default: //changes to default show buffer[1] content correctly { lcd_goto(40); lcd_puts("ERR "); sprintf(message, "%X", buffer[1]); lcd_puts(message); delay_ms(100); } } } etc...... Quote Link to post Share on other sites
Orin 0 Posted January 29, 2008 Report Share Posted January 29, 2008 The following fragment is copied from the source. This compiles and works as expected in 6.70 and compiles without error but does not work under 6.84. Displaying the contents of buffer[1] to an LCD (another part of the same code) shows that it contains the sent values, eg 0xA7 etc., but they are all ignored and default is always executed. (BTW, although the comms is via USB from a PC using virtual comm ports, all that is handled by a FTDI FT245 chip, not the PIC) I have reverted to 6.7 and all is now OK, so no urgency on my part!!Over to you.... do { if(!test_bit(porte,1)) //byte received in USB FIFO buffer... { receive_packet(); //collect packets into buffer switch(buffer[1]) { case 0xA7: //set time { day=buffer[2]; hours=buffer[3]; minutes=buffer[4]; break; } case 0xA8: //set hw times { ON_time_hours=buffer[2]; ON_time_mins=buffer[3]; OFF_time_hours=buffer[4]; OFF_time_mins=buffer[5]; break; } case 0xA9: //boiler temp. { Boiler_temp=buffer[2]; break; } case 0xAA: //hysteresis { hysteresis=buffer[2]; break; } case 0xAB: //read 4 temps. { temp1=ADC_Read(0); delay_ms(2); send(temp1); temp1=ADC_Read(1); send(temp1); delay_ms(2); temp1=ADC_Read(2); send(temp1); delay_ms(2); temp1=ADC_Read(3); send(temp1); delay_ms(2); break; } case 0xAC: //set HW return temp { HW_return = buffer[2]; break; } case 0xAD: //set CH return temp { CH_return = buffer[2]; break; } case 0xAE: { for (n=0;n<255;n++) { send(eeprom_read(n)); delay_us(10); } break; } default: //changes to default show buffer[1] content correctly { lcd_goto(40); lcd_puts("ERR "); sprintf(message, "%X", buffer[1]); lcd_puts(message); delay_ms(100); } } } etc...... What type is buffer? My guess is array of char. Orin. Quote Link to post Share on other sites
Pavel 0 Posted January 29, 2008 Report Share Posted January 29, 2008 What is the type of var 'buffer'? Or even better can you provide full code along with project file (you didn't even mentioned what is your target PIC)? The problem with code fragments like you sent is that we have to add a lot to make it compile and these additions will be certanly different to what you have. And along with missing project file chances we'll pick the same target are minimal. All these may cause completly different behaviour with assotiated waisted time and frustration from both our and your sides. Regards, Pavel Quote Link to post Share on other sites
Orin 0 Posted January 29, 2008 Report Share Posted January 29, 2008 (Compiled for PIC16F88) #pragma OPTIMIZE "1" // Makes no difference: #pragma OPTIMIZE "a" void main() { char fred; char buf[6]; buf[1] = 0xae; switch ( buf[1] ) { case 0xAE: fred = 1; break; default: fred = 0; break; } // <SNIP> } 0049 main 0049 ; { main; function begin 0049 30AE MOVLW 0xAE 004A 1283 BCF STATUS, RP0 004B 1303 BCF STATUS, RP1 004C 00C8 MOVWF main_1_buf+D'1' 004D 0847 MOVF main_1_buf, W 004E 3AAE XORLW 0xAE 004F 1D03 BTFSS STATUS,Z 0050 2854 GOTO label4 0051 3001 MOVLW 0x01 0052 00C6 MOVWF main_1_fred 0053 2855 GOTO label5 0054 label4 0054 01C6 CLRF main_1_fred 0055 label5 Oh dear, the array indexing seems to have gone AWOL. It's actually switching on buf[0]! Workaround is to assign buf[1] to a temporary and switch on the temporary. Orin. Quote Link to post Share on other sites
Pavel 0 Posted January 29, 2008 Report Share Posted January 29, 2008 Looks like a compiler bug. Can't believe this one slipped in. We will fix and release an update ASAP (probably a new release as we have made a few important changes since last release). Thanks for reporting. Regards, Pavel PS: After more investigations this issue doesn't look that bad. It only affects cases when switch uses array elements that are 8 bit long and a constant index. The problem has been fixed and fix will be available in the next release. Quote Link to post Share on other sites
mikew 0 Posted January 29, 2008 Author Report Share Posted January 29, 2008 I can see that any further input from me would be superfluous! Apologies for not providing the essential bits of info., but it was late and I had spent an hour looking for bugs in my VB 6 code, because I 'knew' the PIC C was OK!! Regards, Mike W PS Any thoughts on the non-appearance of flash_loadbuffer? Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.