Fix overflow
uint8_t -> uint16_t
This commit is contained in:
parent
25050d4500
commit
1b6294b04b
@ -23,7 +23,7 @@ int main() {
|
||||
stdout = &USART_stream;
|
||||
|
||||
while (1) {
|
||||
voltage_values();
|
||||
//printf("The values: \n%u , %u\n",VREF_REFSEL_VDD_gc , adcVal);
|
||||
uint16_t adcVal = voltage_values();
|
||||
printf("The values: \n%u , %u\n",VREF_REFSEL_VDD_gc , adcVal);
|
||||
}
|
||||
}
|
||||
@ -34,8 +34,8 @@
|
||||
<targetPluginBoard></targetPluginBoard>
|
||||
<platformTool>nEdbgTool</platformTool>
|
||||
<languageToolchain>XC8</languageToolchain>
|
||||
<languageToolchainVersion>2.46</languageToolchainVersion>
|
||||
<platform>3</platform>
|
||||
<languageToolchainVersion>2.45</languageToolchainVersion>
|
||||
<platform>2</platform>
|
||||
</toolsSet>
|
||||
<packs>
|
||||
<pack name="AVR-Dx_DFP" vendor="Microchip" version="2.3.272"/>
|
||||
@ -147,6 +147,9 @@
|
||||
<property key="program-the-device-with-default-config-words" value="false"/>
|
||||
<property key="remove-unused-sections" value="true"/>
|
||||
</HI-TECH-LINK>
|
||||
<Tool>
|
||||
<property key="debugoptions.useswbreakpoints" value="true"/>
|
||||
</Tool>
|
||||
<XC8-CO>
|
||||
<property key="coverage-enable" value=""/>
|
||||
<property key="stack-guidance" value="false"/>
|
||||
@ -169,6 +172,9 @@
|
||||
<property key="user-pack-device-support" value=""/>
|
||||
<property key="wpo-lto" value="false"/>
|
||||
</XC8-config-global>
|
||||
<nEdbgTool>
|
||||
<property key="debugoptions.useswbreakpoints" value="true"/>
|
||||
</nEdbgTool>
|
||||
</conf>
|
||||
</confs>
|
||||
</configurationDescriptor>
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
|
||||
void sensor_init(void) {
|
||||
/* Disable digital input buffer */
|
||||
|
||||
}
|
||||
|
||||
void ADC0_init(void) {
|
||||
@ -26,14 +27,14 @@ uint16_t ADC0_read(void) {
|
||||
while (!(ADC0.INTFLAGS & ADC_RESRDY_bm)) {
|
||||
;
|
||||
}
|
||||
/* Clear the interrupt flag by writing 1: */
|
||||
// Clear the interrupt flag by writing 1:
|
||||
ADC0.INTFLAGS = ADC_RESRDY_bm;
|
||||
return ADC0.RES;
|
||||
}
|
||||
|
||||
uint8_t voltage_values(void) {
|
||||
uint16_t voltage_values(void) {
|
||||
/* Gets values */
|
||||
uint8_t adcVal = ADC0_read();
|
||||
uint16_t adcVal = ADC0_read();
|
||||
VREF.ADC0REF = VREF_REFSEL_VDD_gc;
|
||||
return adcVal;
|
||||
}
|
||||
@ -53,7 +53,7 @@ void ADC0_init(void);
|
||||
//Start ADC conversion
|
||||
uint16_t ADC0_read(void);
|
||||
// Gets the value from sensor and internal voltage
|
||||
uint8_t voltage_values(void);
|
||||
uint16_t voltage_values(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user