t whant to send adc result to usart serial port i have problem in program help me please i use 16f876a
Code: Select all
//////////*************************************************************////////
///////data acquisition program ////programed by eng.s.slimane //////////////
unsigned int temp_res;
unsigned char ch;
long tlong;
//////////////////////Lecture de la Temperature//////////////////////
void adc()
{
temp_res = ADC_Read(2); // Get 10-bit results of AD conversion
tlong = (long)temp_res * 5000; // covert adc reading to milivolts
tlong = tlong / 1023; // 0..1023 -> 0-5000mV
}
/////////// transfert du text à l'interface graphique ///////////////
void Text_To_Usart(unsigned char *m)
{
unsigned char j;
j = 0;
while(m[j] != 0)
{
Usart_Write(m[j]);
j++;
}
}
///////////////////Le Pregramme Principale////////////////////////
void main()
{
TRISB =0x00;
TRISA =0b000100;
TRISC =0b10110000;
// Initialize USART module at 9600 bps
Usart_init(9600);
// Wait for USART module to stabilize
delay_ms(100);
while(1)
{
// transfet à l'interface
PORTB = temp_res ;
ch = tlong / 1000;
Delay_ms(10);
Text_To_Usart("R");
Usart_Write(ch);
Usart_Write(ch1);
Usart_Write(0x0D);
Usart_Write(0x0A);
delay_ms(10);
adc();
}
}
///////////////////////////**********************//////////////////////////////