Hello ,
I've been recently trying to interface my atmega32 to a WINSTAR
WH1601A LCD display .
It works ( most of the time ) when I'm trying to send discrete characters .
Now i'm trying to send a live feed of the ADC result to the LCD and it's not working .
I'm trying to covert the result to a string and then send it.
My LCD is showing blank (no results)
Could someone see where my error in the code is? Particularly in the conversion using ITOA.
Note: I'm only linking snippets of the relevant code
Thanks in advance
And the main routine:
I've been recently trying to interface my atmega32 to a WINSTAR
WH1601A LCD display .
It works ( most of the time ) when I'm trying to send discrete characters .
Now i'm trying to send a live feed of the ADC result to the LCD and it's not working .
I'm trying to covert the result to a string and then send it.
My LCD is showing blank (no results)
Could someone see where my error in the code is? Particularly in the conversion using ITOA.
Note: I'm only linking snippets of the relevant code
Thanks in advance
Rich (BB code):
int convert()
{
ADCSRA |= ( 1 << ADSC);
while((ADCSRA & (1<< ADSC)));
return ADC;
}
void SendString(char *CString)
{
while(*CString > 0)
{
SendCharacter(*CString++);
}
}
And the main routine:
Rich (BB code):
int main(void)
{
ADMUX |= ( 1 << REFS0);
ADCSRA |= ( 1 << ADEN) | (1 << ADPS1) | ( 1 << ADPS0);
DDRD |= (1 << 2 ) | ( 1 << 5 ) | ( 1 << 7);
_delay_ms(100);
SendCommand(0x01); //Clear Screen 0x01 = 00000001
_delay_ms(2);
SendCommand(0x38);
_delay_us(50);
while(1)
{
convert();
SendCommand(0x01);
char adcResult[4];
itoa(ADC , adcResult, 10);
SendString(adcResult);
_delay_ms(10);
}
}