lalasaib82
Newbie level 3
- Joined
- Mar 2, 2010
- Messages
- 3
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,492
Hi all
Please help me to make the code..
Chip: PIC16F877, MAX232
Compiler: Hi tech C, MPLAB IDE
Requirement: 10 bit ADC to send data serially on Mobile and then send SMS on SMS query. i.e. "Data" So the Mobile should send the ADC result.
Please edit the program below if some one can....
Added after 1 minutes:
On MPLAB IDE i am getting the error message "usart.h" directory not found.
Please help me to make the code..
Chip: PIC16F877, MAX232
Compiler: Hi tech C, MPLAB IDE
Requirement: 10 bit ADC to send data serially on Mobile and then send SMS on SMS query. i.e. "Data" So the Mobile should send the ADC result.
Please edit the program below if some one can....
#include <stdio.h>
#include <htc.h>
#include <pic16f877.h>
#include "usart.h"
__CONFIG(DEBUGEN & WDTDIS & LVPDIS); // Setup the configuration word for ise with ICD2
/* Sample code to set up the A2D module */
void init_a2d(void){
ADCON0=0; // select Fosc/2
ADCON1=0x80; // select left justify result. A/D port configuration 0
ADON=1; // turn on the A2D conversion module
}
/* Return an 8 bit result */
unsigned ((ADRESH<<8)+(ADRESL))(unsigned char channel){
channel&=0x07; // truncate channel to 3 bits
ADCON0&=0xC5; // clear current channel select
ADCON0|=(channel<<3); // apply the new channel select
ADGO=1; // initiate conversion on the selected channel
while(ADGO)continue;
return(ADRESH); // return 8 MSB of the result
}
void main(void){
unsigned char x;
init_a2d(); // initialise the A2D module
GIE=0; // we don't want interrupts
TRISB=0xF0; // the lower four bits of POTRB will be used in output mode
for(;{
x=read_a2d(1); // sample the analog value on RA0
PORTB = (8>>(x>>6)); // Use the 2 MS Bits of the result to select the bit position of the LED on PORTB
}
INTCON=0; // purpose of disabling the interrupts.
init_comms(); // set up the USART - settings defined in usart.h
// Output a message to prompt the user for a keypress
printf("\rPress a key and I will echo it back:\n");
while(1){
x = getch(); // read a response from the user
printf("\rI detected [%c]",x); // echo it back
}
}
Added after 1 minutes:
On MPLAB IDE i am getting the error message "usart.h" directory not found.