vinayakdabholkar
Advanced Member level 4
- Joined
- Nov 29, 2009
- Messages
- 114
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,296
- Location
- goa
- Activity points
- 2,195
i have just made this simple code and dont seem to understand why its not working. When i put the hex file in proteus i dont get any output on port D
Code:
/*
* File: LED.c
*
* Created on 13 March, 2013, 3:10 PM
*/
[ATTACH=CONFIG]88413._xfImport[/ATTACH]
#include <stdio.h>
#include <stdlib.h>
#include <pic18f4520.h>
#pragma config OSC=HS
#pragma config WDT=OFF
#pragma config LVP=OFF
#pragma config DEBUG=OFF
#pragma config MCLRE=OFF
#pragma config PBADEN = OFF //portB 0to 4 digital - not analogue
/*
*
*/
void ADCInt()
{
ADCON2=0b10001010;
ADCON1=0b00111011;
}
unsigned int ADCRead(unsigned char ch)
{
if(ch>13)return 0;
ADCON0bits.ADON=1;
ADCON0bits.GO=1;
while(ADCON0bits.DONE==1);
ADCON0bits.ADON=0;
return ADRESL;
}
void main()
{
char val;
TRISAbits.RA0=1;
TRISD=0x00;
ADCInt();
val=ADCRead(0);
LATD=val;
//LATDbits.LATD0=1;
}