Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] PIC16f676 ADC problem (Mikroc)

Status
Not open for further replies.

sachinkallely

Newbie level 3
Newbie level 3
Joined
Jan 1, 2011
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
hyderabad
Visit site
Activity points
1,314
Hi i am using pic16f676 for a cyclic timer. I am coding in MikroC. Attaching the code below. Proteas simulation is giving out errors.Help me out please

Code:
unsigned long int x,k;
void main()
{
  ADCON1=0x80;
  TRISA=0xFF;
  TRISC=0x00;
  do {
    x = ADC_Read(0);
    k=(x/4);
    if(0<k && k<128)
    {
        PORTC.F5=1;
        Delay_Ms(1000);
        PORTB.F5=0;
        Delay_Ms(1000);
      }
    if(128<k && k<255)
    {
        PORTB.F5=1;
        Delay_Ms(3000);
        PORTB.F5=0;
        Delay_Ms(3000);
    }
  } while(1);
}
 

Unless you specify properly what errors are happening, will not be able to get any effective help. Anyway, taking an overview at code posted above, some lines seems a little strange, such that:


Code C - [expand]
1
if(0<k && k<128)



I would suggest you replace it for...


Code C - [expand]
1
if ( ( k > 0 ) && ( k < 128 ) )




+++
 

The error is as follows
ff.pngUntitled.png
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top