Cheetos
Member level 3
how do i send my data from ADC to Usart? This is my code, and i am not able to send the data that i need. I am not that good in programming microcontrollers. i am currently using PIC16F877A and MikroC
void main(){
ADCON1 = 0x00; // 8-bit converter, 0000 Ports E and A are analog inputs and Vref+ is VDD Vref- is Vss,
TRISA = 0xFF; // Port A input
PORTB = 0x00;
TRISB = 0x00;
TRISC = 0xC0; // only TX pin is made output on port C
TRISD = 0x00;
Usart_Init(9600);
PORTB = 0xFF;
delay_ms(1000);
PORTB = 0x00;
while(1){
Vout=Adc_read(0);
Usart_Write('C');
Usart_Write('U');
Usart_Write('R');
Usart_Write('R');
Usart_Write('E');
Usart_Write('N');
Usart_Write('T');
Usart_Write('\r');
Usart_Write(Adc_read(0));
}
}
void main(){
ADCON1 = 0x00; // 8-bit converter, 0000 Ports E and A are analog inputs and Vref+ is VDD Vref- is Vss,
TRISA = 0xFF; // Port A input
PORTB = 0x00;
TRISB = 0x00;
TRISC = 0xC0; // only TX pin is made output on port C
TRISD = 0x00;
Usart_Init(9600);
PORTB = 0xFF;
delay_ms(1000);
PORTB = 0x00;
while(1){
Vout=Adc_read(0);
Usart_Write('C');
Usart_Write('U');
Usart_Write('R');
Usart_Write('R');
Usart_Write('E');
Usart_Write('N');
Usart_Write('T');
Usart_Write('\r');
Usart_Write(Adc_read(0));
}
}