Hi Jeff,
I find a disorder in your header file:
// 3.3V Current Sensor
const ADC_INIT_CHANNEL_STRUCT ADC0_I_SENSE_3_3V_Channel =
{
ADC0_SOURCE_AD3, // 3.3V Current Sensor,physical ADC
ADC_CHANNEL_MEASURE_ONCE | ADC_CHANNEL_START_NOW,
NUM_SAMPLES_IN_ONE_RUN, // number of samples in one run sequence
START_OFFSET, //
PERIOD, // period in us
SCALE_RANGE, // scale range of result (not used now)
CIRCULAR_BUFFER_SIZE, // circular buffer size (sample count)
ADC_PDB_TRIGGER, // logical trigger ID that starts this ADC channel
NULL, // no lwevent used
0 // lwevent bits
};
// 5V Voltage Sensor
const ADC_INIT_CHANNEL_STRUCT ADC0_VOLT_SENSE_5V_Channel =
{
ADC0_SOURCE_AD1, // 3.3V Voltage Sensor,physical ADC channel
ADC_CHANNEL_MEASURE_ONCE | ADC_CHANNEL_START_NOW,
NUM_SAMPLES_IN_ONE_RUN, // number of samples in one run sequence
PERIOD, // period in us
START_OFFSET, //
SCALE_RANGE, // scale range of result (not used now)
CIRCULAR_BUFFER_SIZE, // circular buffer size (sample count)
ADC_PDB_TRIGGER, // logical trigger ID that starts this ADC channel
NULL, // no lwevent used
0 // lwevent bits
};
// AC Current Sensor
const ADC_INIT_CHANNEL_STRUCT ADC0_I_SENSE_AC_Channel =
{
#if 0
ADC0_SOURCE_AD5B, // not working // AC current Sensor,physical ADC channel
#else
ADC0_SOURCE_AD3, // !!!!! using working channel here even thou it is not the correct channel.!!!!!
#endif
ADC_CHANNEL_MEASURE_ONCE | ADC_CHANNEL_START_NOW,
NUM_SAMPLES_IN_ONE_RUN, // number of samples in one run sequence
START_OFFSET, //
PERIOD, // period in us
SCALE_RANGE, // scale range of result (not used now)
CIRCULAR_BUFFER_SIZE, // circular buffer size (sample count)
ADC_PDB_TRIGGER, // logical trigger ID that starts this ADC channel
NULL, // no lwevent used
0 // lwevent bits
};
Why ADC0_VOLT_SENSE_5V_Channel, the defination of PERIOD, START_OFFSET is not like other channel?
Whether it should be :
// 5V Voltage Sensor
const ADC_INIT_CHANNEL_STRUCT ADC0_VOLT_SENSE_5V_Channel =
{
ADC0_SOURCE_AD1, // 3.3V Voltage Sensor,physical ADC channel
ADC_CHANNEL_MEASURE_ONCE | ADC_CHANNEL_START_NOW,
NUM_SAMPLES_IN_ONE_RUN, // number of samples in one run sequ
START_OFFSET, //
PERIOD, // period in us
SCALE_RANGE, // scale range of result (not used now)
CIRCULAR_BUFFER_SIZE, // circular buffer size (sample count)
ADC_PDB_TRIGGER, // logical trigger ID that starts this ADC channel
NULL, // no lwevent used
0 // lwevent bits
};
I am not familiar with your mqx code, I just find the definiation has the difference, I don't know whether it has problem when you call : VOLT_SENSE_5V_INDEX
Besides, please also check the PORTx_PCRn[MUX], when the problem happens.
Have a great day,
Jingjing
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------