Hi,
the following code always gives 0 as adc_input (after the first loop):
#include "board.h"
#include "../mods/uarttx/uarttx.h"
int main(void)
{
// Init board
Board_Init();
// Init ADC
Chip_ADCDAC_Init(NSS_ADCDAC0);
Chip_ADCDAC_SetMuxADC(NSS_ADCDAC0, ADCDAC_IO_ANA0_0);
Chip_ADCDAC_SetInputRangeADC(NSS_ADCDAC0, ADCDAC_INPUTRANGE_WIDE);
Chip_ADCDAC_SetModeADC(NSS_ADCDAC0, ADCDAC_SINGLE_SHOT);
volatile int adcInput=99;
/* Blink with a period of 250ms+250ms, or 2Hz */
while (1) {
// Toggle LED
LED_Toggle(LED_RED);
// Read out ADC
Chip_ADCDAC_StartADC(NSS_ADCDAC0);
while (!(Chip_ADCDAC_ReadStatus(NSS_ADCDAC0) & ADCDAC_STATUS_ADC_DONE)) { /* wait */ }
adcInput = Chip_ADCDAC_GetValueADC(NSS_ADCDAC0);
// UART print to give out data
UartTx_Init();
UartTx_Printf("ADC:%d\n", adcInput);
UartTx_DeInit();
// Pause
Chip_Clock_System_BusyWait_ms(250);
}
return 0;
}
I've disabled code optimization in the preferences and double checked that there is ~1V at the ADCDAC_IO_ANA0_0 of the NHS3152 demo board.
What am I missing? Help appreciated.
BR
Till
已解决! 转到解答。
Hi,
It seems that in the SDK example, a line mysteriously disappeared.
Can you add this line and try again?
Chip_IOCON_SetPinConfig(NSS_IOCON, IOCON_ANA0_5, IOCON_FUNC_1);
From the user manual UM10876:
and:
I'll make sure a future SDK release restores this line - truly sorry for this hickup!
Best,
Dries.
Hi,
It seems that in the SDK example, a line mysteriously disappeared.
Can you add this line and try again?
Chip_IOCON_SetPinConfig(NSS_IOCON, IOCON_ANA0_5, IOCON_FUNC_1);
From the user manual UM10876:
and:
I'll make sure a future SDK release restores this line - truly sorry for this hickup!
Best,
Dries.
In the function:
int Chip_ADCDAC_GetValueADC(NSS_ADCDAC_T *pADCDAC)
{
return pADCDAC->ADCDR & ADCDAC_ADC_VALUE_MASK;
}
I get the error:
Multiple errors reported.
1) Failed to execute MI command:
-var-update 1 var2
Error message from debugger back end:
value has been optimized out
What can I do to fix it? Compiler optimization is already deactivated.
BR
Till
Half fix: I found that the function:
int Chip_ADCDAC_GetValueADC(NSS_ADCDAC_T *pADCDAC)
{
return pADCDAC->ADCDR & ADCDAC_ADC_VALUE_MASK;
}
was located outside of the project and was therefore optimized.
Nevertheless, the example code does not work. Is the ADC section buggy, there is also another open question on this?
https://community.nxp.com/message/1025268?q=nhs31
Help really appreciated!