Compiler Error?

(instructions, reset, WDT, specifications...) PIC17Cxx, PIC18Fxxx

Re: Compiler Error?

Postby ric » Thu Aug 14, 2014 11:25 pm

ahhh, just a moment. You said "will step down six lines and then hop to line 13 (the last line). "

Can you explain exactly where it jumped to.
I thought you meant the last functional line, which is " led_mode[1] = LED_ON; // Red LED", but that is line#15.
Line#13 is the second "else"
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 659
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Re: Compiler Error?

Postby tunelabguy » Fri Aug 15, 2014 8:04 pm

SLTom992 wrote:I'm not sure I understand you. I have the proper battery voltage measured. In the one case it lights the green LED and with those two instructions revered it lights the red LED instead.

This description of the outcome is not consistent with your description of the sequence of instructions that would produce this outcome. If the battery voltage is above 8.8 volts, then the code should execute the following instructions:
Code: Select all
led_mode[1] = OFF;            // Red LED
led_mode[2] = LED_ON;       // Grn LED

If you are claiming that the result is a red light, then I assume you are claiming the following instructions are executed:
Code: Select all
led_mode[1] = LED_ON;       // Red LED
led_mode[2] = OFF;             // Grn LED

But none of your descriptions of single-stepping said that these were the instructions that were executed. That is why I assumed you were perhaps mistaken about which instructions were executed and deduced the "compiler error" strictly from observing which LED was turned on in the end. Despite being asked repeatedly to clarify which instructions you say are being executed, you have so far refused to clarify your hopelessly vague description.

I also asked you, and you failed to answer me, how the setting of led_mode[1] and led_mode[2] result in making the red or green LEDs go on or off. The syntax looks a lot like an array in memory, not like direct access to an I/O port. If you are claiming the compiler messed up because the red LED is on, you must consider the possibility that you messed up in making the setting of this array in memory affect and I/O port that is presumably controlling the LEDs.

If you want to make sense of debugging, you must either:

1. Turn off all optimizations. Or..
2. Debug at the machine language level, not the C-code level, because optimizations can make that very confusing.

Since this code is very simple, my guess is that this code is executing fine, but you are doing something wrong with the array led_mode[] elsewhere in the code to make the red LED come one.
User avatar
tunelabguy
Verified identity
 
Posts: 29
Joined: Sun Jul 20, 2014 9:41 pm
PIC experience: Professional 5+ years with MCHP products

Re: Compiler Error?

Postby jtemples » Fri Aug 15, 2014 8:19 pm

Another slightly odd thing about this code is that it refers to indices 1 and 2 of an array; is it really an array of three elements?
jtemples
Verified identity
 
Posts: 195
Joined: Sun May 25, 2014 2:23 am
Location: The 805
PIC experience: Professional 5+ years with MCHP products

Re: Compiler Error?

Postby SLTom992 » Mon Aug 18, 2014 6:17 pm

The array led_on[] is used because the LEDs are blinked at different rates to mean different things though you can think of them merely as LAT's.

It appears that the original problem was not caused by the code optimizer but from the way I was using the ADRESH and ADRESL registers and testing them separately instead of combining them into a single INT as is shown in the code displayed. How THAT could have caused the problem I don't know but it makes no difference now in which order I place the final instructions in the subroutine.

If I have the time I'll dig though my back-ups and see if I can find the original code for your perusal.
SLTom992
 
Posts: 58
Joined: Tue Jun 10, 2014 8:59 pm
PIC experience: Professional 1+ years with MCHP products

Previous

Return to 16-Bit Core

Who is online

Users browsing this forum: No registered users and 9 guests

cron