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
"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 ?"
Just multiply it by 102.4?
Have you verified the hardware?
What voltage range does the circuit show that the ADC input should have?
What voltage range have you measured on the ADC input?
What reading does the data sheet say that your ADC should return for such input voltages and with the voltage reference that your board is using?
I have already verified the volage with UART. In hexadecimal as maximal value I become 0b0000001111111111
That means no hardware problem. Any suggestions?
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?