Hello Keil users,
I'm trying to display a ADC value on eval board. ( I already post a similar thread but this time is not the same).
The problem is that ADC displayed on board varies between 0 and 10. And I want it to vary between 0 and 1024.
Any idea ?
short AD_value = 0x00 void ADC_IRQ_Handler(void) { ADC->CR &= 0xFFFE; /* Clear STR bit (Start Conversion) */ ADC->CR &= 0x7FFF; /* Clear End of Conversion flag */ VIC0->VAR = 0; /* Acknowledge Interrupt */ VIC1->VAR = 0; AD_value = ADC->DR0 & 0x03FF; /* AD value for global usage (10 bit) */ ADConversation = TRUE; /* Signal, that AD-conversion has finished */ }
And the called function is
ADConversation = FALSE; ADC->CR |= 0x0403; /* Set STR bit (Start Conversion) */ while(!ADConversation) {} /* Wait until AD-conversation has finished */ lcd_init(); lcd_clear(); set_cursor(0,0); sprintf(text1,"Analog Value %5d",AD_value); lcd_print(text1);
ADConversation is a bool.
Thanks in advance. Adel
Your solution is very professional. I have to comment it. As comment what can I say for multiplying by 102.4 ? You are tip is very helpfull and very professional
Splendid.
So if you have verified that you really manage to set all 10 bits in the ADC, why then do you bring the ADC into the discussion?
Have you verified that the text buffer and the display has room for the two last digits of the number?
Hi Per, Thanks for answering. I want to display this value of ADC into the board.
this a good question. in my text1 variable I defined this
char text1[30];
Maybe it is not the best choice?