Skip to content

Commit

Permalink
Fix incorrect ADC channel mapping (#40)
Browse files Browse the repository at this point in the history
* fix erroneous channel identifiers, was wrong for channels 16-19
* also add some explicit sequencer disables and other updates to ensure that the ADC modules initialize correctly.
  • Loading branch information
pwittich authored Feb 11, 2020
1 parent 331bd69 commit 2c912ae
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions projects/cm_mcu/ADCMonitorTask.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,27 @@ struct ADC_Info_t {
// channel sensor.
static
struct ADC_Info_t ADCs[] = {
{12, "VCC_12V", 6.},
{13, "VCC_2V5", 2.},
{14, "VCC_M3V3", 2.},
{16, "VCC_3V3", 2.},
{ 7, "VCC_1V8", 1.},
{15, "VCC_M1V8", 1.},
{ 3, "V_VCCINT", 1.},
{ 8, "K_VCCINT", 1.},
{ 0, "V_MGTY1_AVTT", 1.},
{19, "V_MGTY2_AVTT", 1.},
{11, "K_MGTH_AVTT", 1.},
{ 4, "K_MGTY_AVTT", 1.},
{ 2, "V_MGTY1_VCCAUX", 1.},
{17, "V_MGTY2_VCCAUX", 1.},
{ 6, "K_MGTY_VCCAUX", 1.},
{ 9, "K_MGTH_VCCAUX", 1.},
{ 1, "V_MGTY1_AVCC", 1.},
{18, "V_MGTY2_AVCC", 1.},
{ 5, "K_MGTY_AVCC", 1.},
{10, "K_MGTH_AVCC", 1.},
{ADC_CTL_TS, "TM4C_TEMP", 1.}, // this one is special, temp in C
{ADC_CTL_CH12, "VCC_12V", 6.},
{ADC_CTL_CH13, "VCC_2V5", 2.},
{ADC_CTL_CH14, "VCC_M3V3", 2.},
{ADC_CTL_CH16, "VCC_3V3", 2.},
{ADC_CTL_CH7, "VCC_1V8", 1.},
{ADC_CTL_CH15, "VCC_M1V8", 1.},
{ADC_CTL_CH3, "V_VCCINT", 1.},
{ADC_CTL_CH8, "K_VCCINT", 1.},
{ADC_CTL_CH0, "V_MGTY1_AVTT", 1.},
{ADC_CTL_CH19, "V_MGTY2_AVTT", 1.},
{ADC_CTL_CH11, "K_MGTH_AVTT", 1.},
{ADC_CTL_CH4, "K_MGTY_AVTT", 1.},
{ADC_CTL_CH2, "V_MGTY1_VCCAUX", 1.},
{ADC_CTL_CH17, "V_MGTY2_VCCAUX", 1.},
{ADC_CTL_CH6, "K_MGTY_VCCAUX", 1.},
{ADC_CTL_CH9, "K_MGTH_VCCAUX", 1.},
{ADC_CTL_CH1, "V_MGTY1_AVCC", 1.},
{ADC_CTL_CH18, "V_MGTY2_AVCC", 1.},
{ADC_CTL_CH5, "K_MGTY_AVCC", 1.},
{ADC_CTL_CH10, "K_MGTH_AVCC", 1.},
{ADC_CTL_TS, "TM4C_TEMP", 1.}, // this one is special, temp in C
};

static float fADCvalues[ADC_CHANNEL_COUNT]; // ADC values in volts
Expand Down Expand Up @@ -206,6 +206,8 @@ void ADCMonitorTask(void *parameters)
// handle error here
configASSERT(0);
}
ROM_ADCSequenceDisable(ADC1_BASE, 0);

// ADC0,first sequence
initADC0FirstSequence();
TaskNotifyADC = xTaskGetCurrentTaskHandle();
Expand All @@ -220,6 +222,7 @@ void ADCMonitorTask(void *parameters)
// handle error here
configASSERT(0);
}
ROM_ADCSequenceDisable(ADC0_BASE, 1);


// second sequence for ADC0
Expand All @@ -237,6 +240,8 @@ void ADCMonitorTask(void *parameters)
// handle error here
configASSERT(0);
}
ROM_ADCSequenceDisable(ADC0_BASE, 1);

initADC1SecondSequence();
TaskNotifyADC = xTaskGetCurrentTaskHandle();
ROM_ADCProcessorTrigger(ADC1_BASE, 0);
Expand All @@ -252,6 +257,7 @@ void ADCMonitorTask(void *parameters)
// handle error here
configASSERT(0);
}
ROM_ADCSequenceDisable(ADC1_BASE, 0);

// convert data to float values
for ( int i = 0; i < ADC_CHANNEL_COUNT; ++i ) {
Expand Down

0 comments on commit 2c912ae

Please sign in to comment.