Electronics > Proteus

Problem with PIC12F675 simulation in Proteus

(1/2) > >>

I'm playing around with Proteus, so I made this circuit with the intention to control the blinking delay with a pot

The code is here:

--- Code: ---#include <xc.h>
#define _XTAL_FREQ 4000000

unsigned int ADCRead()
   //ADON=1;  //switch on the adc module

   GO_DONE=1;  //Start conversion

   while(GO_DONE); //wait for the conversion to finish

   ADON=0;  //switch off adc

   return ADRESH;

void main(void)
    TRISIO = 0b00111110;
    ADCON0 = 0b00000101;
    ANSEL  = 0b00010010;
    unsigned int zx = ADCRead();
   while (1){
      GPIO = 0b00000001;
      __delay_ms (500);
      GPIO = 0b00000000;
      __delay_ms (500);

--- End code ---

Everything works perfectly, and all the variables take the values they should, for example here's a screenshot with the pot set to 50%

But if I try to put the variable zx (ie the ADC result) into __delay_ms, then the code doesn't compile and the compiler error code is somewhat cryptic:

--- Code: ---(1273) Omniscient Code Generation not available in Free mode (warning)
(908) exit status = 1
(908) exit status = 1
make: *** [Debug.cof] Error 1

Error code 2

--- End code ---

Check to see if the delay routines are available under debug mode.

If not, write your own delay routines.

they are not. they should be built-in macros.. the debugger gets grazy for a while when you have to step past them

XC8 built-in delay routines only support a literal constant or an expression composed of literal constants as a parameter.   If you need a variable delay, wrap a fixed delay (using the builtin routines) in a loop, with the desired delay as the loop count.

Stepping through delays of more than a few tens of instruction cycles is a PITA.  Put a breakpoint after the delay and run to it at full speed.

P.S. Your question has sweet F.A. to do with Proteus.  Why confuse the issue by mentioning it?

i think delay_ms function don't take variable, just constant, the compiler add this delays in code.
Build your own delay function or just use PWM module (didn't check DS of this PIC, correct me if it does not have one) , you changing both delays value, so basically you changing the blinking frequency.


[0] Message Index

[#] Next page

There was an error while thanking
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod