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