How would I go about making this better my code is like this
Ok that works great for a byte I want send the whole 10 bit's of the ADC value.
If I changed this to write unsigned char I should be good Like this
That didn't do as planed need to figure some changes here too
Code:
void UART_Write(char data)
{
while(!TRMT);
TXREG = data;
}
If I changed this to write unsigned char I should be good Like this
Code:
void UART_WriteLong(unsigned char data)
{
while(!TRMT);
TXREG = data;
}
Code:
unsigned int ADCRead(unsigned char ch)
{
if(ch>13) return 0; //Invalid Channel
ADCON0=0x00;
ADCON0=(ch<<2); //Select ADC Channel
ADON=1; //switch on the adc module
GODONE=1; //Start conversion
while(GODONE); //wait for the conversion to finish
ADON=0; //switch off adc
return ADRES;
}
Last edited: