![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| Hi, can you guys tell me what's wrong in this C code. Code: #include <pic1687x.h>
#include<pic.h>
void main(void)
{
TRISA = 0xFF; //analog input
TRISE = 0xFF; //analog input
TRISB = 0x00;
TRISC = 0x00;
TRISD = 0x00;
ADCON1 = 0x00; //port A and E as analog io
ADCON0 = 0x00;
ADGO = 1;
while(ADGO)
continue;
RBIE = 1; // enable Port B change interrupt
PEIE = 1; // enable peripheral interrupt
GIE = 1;
PORTB = 0x00;
PORTC = 0x00;
PORTD = 0x00;
while(1)
{
if(RA0 == 1) //INPUT FROM PUSH BUTTON
{
RC0=1; // OUTPUT TO LED
RC1=1;
}
else
{
PORTC =0x00;
}
}
} | |
| |
| | (permalink) |
| You configured AN0 as analog input, while it should be a digital input. Change the ADCON1 settings. Remove the following lines: Code: ADGO = 1;
while(ADGO==1)
continue; Last edited by eng1; 11th September 2007 at 04:40 PM. | |
| |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| | ||||
| Title | Starter | Forum | Replies | Latest |
| Need help with Intel Assembly Language and PIC16F877 | avinsinanan | Micro Controllers | 10 | 4th March 2008 11:02 AM |
| Pspice LED Error | kogula14 | Electronic Projects Design/Ideas/Reviews | 3 | 14th March 2007 05:03 AM |
| Need some help with a code provided by ATMEL | ikalogic | Micro Controllers | 1 | 23rd January 2007 03:46 PM |
| Z8 Encore Error index out of range | mootaccount | Micro Controllers | 2 | 17th October 2006 03:23 PM |
| Help in programming PIC16F877..... | Azhar Ali chohan | Micro Controllers | 3 | 24th June 2003 12:08 PM |