重新启动后adc采样概率性所有值为0,请问怎么解决
-
因为同时采样了芯片内部的温度adc,理论上不能所有adc的值都是0,请帮忙看看
代码如下:
typedef struct
{
// ADC_data ADC_Channel; //ADC²ÉÑùͨµÀ-Ó¦ÓÃ
volatile unsigned char ADC_SamplingChannel; // ADC²ÉÑùͨµÀ
volatile unsigned char ADC_CurrentSamplingChannel; // ADC²ÉÑùͨµÀ
volatile unsigned short ADC_ConversionBuff[ADCALLCHANNEL_DEPTH]; // ADC²ÉÑùÊý¾Ý»º´æ
volatile unsigned int ADC_ConversionCount; // ADCͨµÀÇл»ÑÓʱ¼ÇÊý
volatile unsigned char ADC_ConversionFlag; // ADCµ¥Í¨µÀ¶à´Î²ÉÑùÍê³É±êʶ
} ADC_Control;
ADC_Control ADC0_Control;
const adc_converter_config_t adcInitConfig = {
.clockDivider = 0U,
.startTime = 64,//0x20,
.sampleTime = 10,//0xFF,//0x2C,
.overrunMode = false,
.autoOffEnable = false,
.waitEnable = false,
.trigger = ADC_TRIGGER_HARDWARE,
.align = ADC_ALIGN_RIGHT,
.resolution = ADC_RESOLUTION_12BIT, //²ÉÑùʱ¼ä=£¨ADC_RESOLUTION_12BIT+2+sampleTime)*²ÉÑùʱÖÓÖÜÆÚ
.dmaWaterMark = ADC_SEQUENCE_LENGTH - 1,
.dmaEnable = true,
.compareConfig = {
.compareEnable = false,
.compareAllChannelEnable = false,
.compHigh = 0x00U,
.compLow = 0x00U,
.compIntEnable = false
},
.sequenceConfig = {
.channels = {
ADC_INPUTCHAN_EXT9,
ADC_INPUTCHAN_EXT3,
ADC_INPUTCHAN_EXT1,
ADC_INPUTCHAN_EXT0,
0x10, //MCU ÄÚÖÃζȲɼ¯
// ADC_INPUTCHAN_EXT9,
// ADC_INPUTCHAN_EXT3,
// ADC_INPUTCHAN_EXT1,
// ADC_INPUTCHAN_EXT0,}, .totalChannels = ADC_SEQUENCE_LENGTH, .sequenceMode = ADC_CONV_LOOP, .sequenceIntEnable = false, .convIntEnable = false }
};
const dma_transfer_config_t adcTransferConfig = {
.srcAddr = (uint32_t)&ADC0->FIFO,
.destAddr = (uint32_t)&ADC0_Control.ADC_ConversionBuff,//g_adc_result[0U],
.destOffset = 0x02U,
.srcOffset = 0x00U,
.srcTransferSize = DMA_TRANSFER_SIZE_2B,
.destTransferSize = DMA_TRANSFER_SIZE_2B,
.srcModulo = DMA_MODULO_OFF,
.destModulo = DMA_MODULO_OFF,
.transferLoopByteCount = (ADC_SEQUENCE_LENGTH * 2),
.loopTransferConfig = &adcLoopTransferConfig,
.destLastAddrAdjust = -(ADC_SEQUENCE_LENGTH * 2),
.interruptEnable = false//true//false
};/* Initialize adc instance */ status |= ADCJqr_Init();
status_t ADCJqr_Init(void)
{
status_t status = STATUS_SUCCESS;
ADC_DRV_ConfigConverter(ADC_INST, &adcInitConfig);/* Initialize DMA module & channels */ status |= DMA_DRV_Init(&dmaController_State, &dmaControllerInitConfig, dmaChnStateArray, dmaChnConfigArray, DMA_CONFIGURED_CHANNELS_COUNT); /* Initiate DMA Loop Transfer */ status |= DMA_DRV_ConfigLoopTransfer(dmaControllerChn0InitConfig.virtChnConfig, &adcTransferConfig); status |= DMA_DRV_StartChannel(DMA_CHN0_NUMBER); // Enable temperature sensor ADC0->CTRL |= 0x1 << ADC_CTRL_TSEN_SHIFT; // ADC_DRV_ConfigConverter(ADC_INST, &adcInitConfig); ADC_DRV_Start(ADC_INST); return status;
}
帮助没办法联网的电脑使用YCT
帮助改进和优化YT CONFIG TOOL,有机会抽取YTM32B1ME0 EVB哦...