View previous topic :: View next topic |
Author |
Message |
cogen
Joined: 30 Jun 2007 Posts: 12
|
Error 91 |
Posted: Sat Jun 30, 2007 1:43 pm |
|
|
Hello all
Pic 12f675
CCS Vers 4.019
When I compile delay_ms(96), I get:
Error 91 "D:\CTI\alteronics\osc\Controller Code\oscillator.c" Line 57(10,12): Expression must be a constant or simple variable ::
If I compile above with delay_ms(95) or delay_ms(97) it compiles fine, any suggestions? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Jun 30, 2007 3:17 pm |
|
|
Post a compilable test program that shows the problem. Make it
complete, but as short as possible. Here's an example of a test program:
http://www.ccsinfo.com/forum/viewtopic.php?t=27950&start=8
Just as that program shows, post all #include, #fuses, and #use
statements. Make the main body of the program be very short. |
|
|
cogen
Joined: 30 Jun 2007 Posts: 12
|
|
Posted: Sat Jun 30, 2007 8:16 pm |
|
|
Code: | #include "D:\CTI\alteronics\osc\Controller Code\PWM_osc\temp.h"
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_32);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC);
setup_vref(FALSE);
// TODO: USER CODE!!
while(1)
{
delay_ms(96);
}
}
|
Error message:
*** Error 91 "D:\CTI\alteronics\osc\Controller Code\oscillator.c" Line 57(10,12): Expression must be a constant or simple variable ::
Code: |
#include "D:\CTI\alteronics\osc\Controller Code\PWM_osc\temp.h"
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_32);
setup_timer_1(T1_DISABLED);
setup_comparator(NC_NC);
setup_vref(FALSE);
// TODO: USER CODE!!
while(1)
{
delay_ms(95);
}
}
Compiles fine.... |
|
|
|
cogen
Joined: 30 Jun 2007 Posts: 12
|
temp.h |
Posted: Sat Jun 30, 2007 8:20 pm |
|
|
Code: |
#include <12F675.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz
#FUSES NOCPD //No EE protection
#FUSES NOPROTECT //Code not protected from reading
#FUSES MCLR //Master Clear pin enabled
#FUSES PUT //Power Up Timer
#FUSES NOBROWNOUT //No brownout reset
#use delay(clock=32768)
|
|
|
|
cogen
Joined: 30 Jun 2007 Posts: 12
|
error message |
Posted: Sat Jun 30, 2007 8:24 pm |
|
|
The error message i posted was pasted from the original program. If you need the error message from the test program I will retype, although the only difference is the line and column numbers: Line 17(10,12) rather than Line 57(10,12)
thanks in advance.
mike |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Jun 30, 2007 11:27 pm |
|
|
It's a bug in the compiler. It's not just your version. I found the
same bug with vs. 3.249 and 4.042. It's also there with the 16F877.
I think it's a problem that's only seen with a very low frequency clock
such as the 32.768 KHz watch crystal.
To study the problem, I modified your program into the test program
shown below.
Code: |
#include <12F675.h>
#device adc=8
#use delay(clock=32768)
#FUSES NOWDT // No Watch Dog Timer
#FUSES LP // Watch Crystal osc
#FUSES NOCPD // No EE protection
#FUSES NOPROTECT // Code not protected from reading
#FUSES MCLR // Master Clear pin enabled
#FUSES PUT // Power Up Timer
#FUSES NOBROWNOUT // No brownout reset
//============================
void main()
{
while(1)
{
delay_ms(93);
delay_ms(94);
delay_ms(95);
delay_ms(97);
}
} |
This produces the loop code shown below. You can see that they use
inline loops to do the delay up to 95 ms. At 97 ms, they call a library
routine (not shown) which does an 1 ms delay. You can see that they
pass it the parameter of 0x61, which is 97 decimal.
It looks to me like they have a problem with their code generator, in the
part that checks when to start using the 1 ms delay routine in the library
code. Somehow, they let the value of 96 fall through, and it's not
considered valid for either the loop or the library delay code. Therefore
it generates an error message. They may be using a "less than" test,
and they need to use a "less than or equal to" test.
You can report this bug and if your maintenance has run out, I think
they'll probably upgrade you to the new working version.
Code: |
.................... while(1)
.................... {
.................... delay_ms(93);
0022: MOVLW F7
0023: MOVWF 20
0024: DECFSZ 20,F
0025: GOTO 024
0026: NOP
0027: NOP
.................... delay_ms(94);
0028: MOVLW FA
0029: MOVWF 20
002A: DECFSZ 20,F
002B: GOTO 02A
002C: NOP
.................... delay_ms(95);
002D: MOVLW FD
002E: MOVWF 20
002F: DECFSZ 20,F
0030: GOTO 02F
.................... delay_ms(97);
0031: MOVLW 61
0032: MOVWF 23
0033: GOTO 004
.................... }
0034: GOTO 022 |
As a work-around, you could do this to get a 96 ms delay:
Code: |
delay_ms(95);
delay_ms(1);
|
One more thing -- you had the 'XT' fuse in your posted code. The data
sheet recommends using the 'LP' fuse with a 32.768 KHz watch crystal,
so I changed it to that. |
|
|
cogen
Joined: 30 Jun 2007 Posts: 12
|
Error 91 |
Posted: Sun Jul 01, 2007 8:30 am |
|
|
Thank you for your response. I will follow up with tech support. I also agree about the low power setting for the watch crystal. I have a fairly long startup using LP and have found that the XT setting starts quickly and works better for development efforts, (a nuance, I know). Again, thank you.
Mike |
|
|
|