![]() |
RTOS_MSPM0
1.1
ECE445M starter code
|
Analog to digital conversion. More...
Files | |
| file | ADC.h |
| Initialize 12-bit ADC0 and/or ADC1. | |
| file | ADCTimer.h |
| Initialize 12-bit ADC0. | |
Macros | |
| #define | ADCVREF_INT 0x200 |
| using ADCVREF_INT means choose internal 2.5V reference for accuracy | |
| #define | ADCVREF_EXT 0x100 |
| using ADCVREF_EXT means choose external reference not tested | |
| #define | ADCVREF_VDDA 0x000 |
| using ADCVREF_VDDA means choose power line 3.3V reference for 0 to 3.3V range | |
| #define | ADCVREF_INT 0x200 |
| using ADCVREF_INT means choose internal 2.5V reference for accuracy | |
| #define | ADCVREF_EXT 0x100 |
| using ADCVREF_EXT means choose external reference not tested | |
| #define | ADCVREF_VDDA 0x000 |
| using ADCVREF_VDDA means choose power line 3.3V reference for 0 to 3.3V range. This is the mode we use in ECE319K | |
Functions | |
| void | ADC0_Init (uint32_t channel, uint32_t reference) |
| Initialize 12-bit ADC0. More... | |
| uint32_t | ADC0_In (void) |
| Trigger ADC measurement and wait for result. More... | |
| void | ADC1_Init (uint32_t channel, uint32_t reference) |
| Initialize 12-bit ADC0. More... | |
| uint32_t | ADC1_In (void) |
| Trigger ADC measurement and wait for result. More... | |
| void | ADC_Init (ADC12_Regs *adc12, uint32_t channel, uint32_t reference) |
| Initialize 12-bit ADC0. More... | |
| uint32_t | ADC_In (ADC12_Regs *adc12) |
| Trigger ADC measurement and wait for result. More... | |
| void | ADC_InitDual (ADC12_Regs *adc12, uint32_t channel1, uint32_t channel2, uint32_t reference) |
| Initialize 12-bit ADC for two channels. More... | |
| void | ADC_InDual (ADC12_Regs *adc12, uint32_t *d1, uint32_t *d2) |
| Trigger two ADC measurements and wait for results. More... | |
| void | ADC_InitTriple (ADC12_Regs *adc12, uint32_t channel1, uint32_t channel2, uint32_t channel3, uint32_t reference) |
| Initialize 12-bit ADC for three channels. More... | |
| void | ADC_InTriple (ADC12_Regs *adc12, uint32_t *d1, uint32_t *d2, uint32_t *d3) |
| Trigger three ADC measurements and wait for results. More... | |
| void | ADC0_InitAve (uint32_t channel, uint32_t n) |
| Initialize 12-bit ADC0 for hardware averaging. More... | |
| void | ADC0_TimerG0_Init (uint32_t channel, uint32_t reference, uint16_t period, uint32_t prescale, uint32_t priority) |
| Initialize 12-bit ADC0. More... | |
| void | ADC1_TimerG8_Init (uint32_t channel, uint32_t reference, uint16_t period, uint32_t prescale, uint32_t priority) |
| Initialize 12-bit ADC1. More... | |
Analog to digital conversion.
| Pin | ADC channel | Sensor |
|---|---|---|
| PA27 | ADC0 channel 0 | J1.8 also MKII light interrupt |
| PA26 | ADC0 channel 1 | J1.6 MKII microphone in |
| PA25 | ADC0 channel 2 | J1.2 MKII Joystick X |
| PA24 | ADC0 channel 3 | J3.27 free |
| PB25 | ADC0 channel 4 | J19.7 (insert 0ohm R74, no U3 OPA2365) |
| PB24 | ADC0 channel 5 | J1.5 also MKII joystick select button |
| PB20 | ADC0 channel 6 | J4.36 free |
| PA22 | ADC0 channel 7 | J24 MKII Accelerometer Y |
| PA15 | ADC1 channel 0 | J3.30 (also DACout) |
| PA16 | ADC1 channel 1 | J3.29 free |
| PA17 | ADC1 channel 2 | J3.28 free |
| PA18 | ADC1 channel 3 | J3.26 MKII Joystick Y |
| PB17 | ADC1 channel 4 | J2.18 free |
| PB18 | ADC1 channel 5 | J3.25 MKII Accelerometer Z |
| PB19 | ADC1 channel 6 | J3.23 MKII Accelerometer X |
| PA21 | ADC1 channel 7 | J17.8 (insert R20, remove R3) |
| Pin | ADC channel | Sensor |
|---|---|---|
| PA27 | ADC0 channel 0 | J1.8 also MKII light interrupt |
| PA26 | ADC0 channel 1 | J1.6 MKII microphone in |
| PA25 | ADC0 channel 2 | J1.2 MKII Joystick X |
| PA24 | ADC0 channel 3 | J3.27 free |
| PB25 | ADC0 channel 4 | J19.7 (insert 0ohm R74, no U3 OPA2365) |
| PB24 | ADC0 channel 5 | J1.5 also MKII joystick select button |
| PB20 | ADC0 channel 6 | J4.36 free |
| PA22 | ADC0 channel 7 | J24 MKII Accelerometer Y |
| uint32_t ADC0_In | ( | void | ) |
Trigger ADC measurement and wait for result.
Trigger a single ADC0 measurement, wait for it to complete, and return the 12-bit result as 0 to 4095. The ADC input voltage range is 0 to 3.3V. Busy-wait synchronization used.
| none |
| void ADC0_Init | ( | uint32_t | channel, |
| uint32_t | reference | ||
| ) |
Initialize 12-bit ADC0.
Initialize 12-bit ADC0 in software-triggered mode to take measurements when the associated function is called. One channel is to be measured
| channel | is the 0 to 7 |
| reference | is ADCVREF_INT, ADCVREF_EXT, ADCVREF_VDDA |
| void ADC0_InitAve | ( | uint32_t | channel, |
| uint32_t | n | ||
| ) |
Initialize 12-bit ADC0 for hardware averaging.
Initialize 12-bit ADC0 in software-triggered mode to take measurements when the associated function is called. One channel is to be measured 2^n times in average.
| channel | is the 0 to 7 |
| n | 0 to 7 |
| void ADC0_TimerG0_Init | ( | uint32_t | channel, |
| uint32_t | reference, | ||
| uint16_t | period, | ||
| uint32_t | prescale, | ||
| uint32_t | priority | ||
| ) |
Initialize 12-bit ADC0.
Initialize ADC0 for Timer G0 triggered sampling
Assuming 80 MHz bus, the sampling is 40MHz/period/prescale
Pin channel
PA27 0
PA26 1
PA25 2
PA24 3
PB25 4
PB24 5
PB20 6
PA22 7
| channel | is the 0 to 7 |
| reference | is ADCVREF_INT, ADCVREF_EXT, ADCVREF_VDDA |
| period | is 16-bit period in bus cycles on Timer G0 |
| prescale | is 8-bit prescale in bus cycles on Timer G0 |
| priority | is 0 to 3 for ADC interrupts |
| uint32_t ADC1_In | ( | void | ) |
Trigger ADC measurement and wait for result.
Trigger a single ADC1 measurement, wait for it to complete, and return the 12-bit result as 0 to 4095. The ADC input voltage range is 0 to 3.3V. Busy-wait synchronization used.
| none |
| void ADC1_Init | ( | uint32_t | channel, |
| uint32_t | reference | ||
| ) |
Initialize 12-bit ADC0.
Initialize 12-bit ADC1 in software-triggered mode to take measurements when the associated function is called. One channel is to be measured
| channel | is the 0 to 7 |
| reference | is ADCVREF_INT, ADCVREF_EXT, ADCVREF_VDDA |
| void ADC1_TimerG8_Init | ( | uint32_t | channel, |
| uint32_t | reference, | ||
| uint16_t | period, | ||
| uint32_t | prescale, | ||
| uint32_t | priority | ||
| ) |
Initialize 12-bit ADC1.
Initialize ADC1 for Timer G8 triggered sampling
Assuming 80 MHz bus, the sampling is 40MHz/period/prescale
Pin channel
PA15 0
PA16 1
PA17 2
PA18 3
PB17 4
PB18 5
PB19 6
PA21 7
| channel | is the 0 to 7 |
| reference | is ADCVREF_INT, ADCVREF_EXT, ADCVREF_VDDA |
| period | is 16-bit period in bus cycles on Timer G8 |
| prescale | is 8-bit prescale in bus cycles on Timer G8 |
| priority | is 0 to 3 for ADC interrupts |
| uint32_t ADC_In | ( | ADC12_Regs * | adc12 | ) |
Trigger ADC measurement and wait for result.
Trigger a single ADC0 or ADC1 measurement, wait for it to complete, and return the 12-bit result as 0 to 4095. The ADC input voltage range is 0 to 3.3V. Busy-wait synchronization used.
| adc12 | is ADC0 or ADC1 |
| void ADC_InDual | ( | ADC12_Regs * | adc12, |
| uint32_t * | d1, | ||
| uint32_t * | d2 | ||
| ) |
Trigger two ADC measurements and wait for results.
Trigger a dual ADC0 or ADC1 measurement, wait for it to complete, and return the two 12-bit results as 0 to 4095. The ADC input voltage range is 0 to 3.3V. Busy-wait synchronization used.
| adc12 | is ADC0 or ADC1 |
| *d1 | address into which the first ADC sample will be stored |
| *d2 | address into which the second ADC sample will be stored |
| void ADC_Init | ( | ADC12_Regs * | adc12, |
| uint32_t | channel, | ||
| uint32_t | reference | ||
| ) |
Initialize 12-bit ADC0.
Initialize 12-bit ADC0 or ADC1 in software-triggered mode to take measurements when the associated function is called. One channel is to be measured
| adc12 | is ADC0 or ADC1 |
| channel | is the 0 to 7 |
| reference | is ADCVREF_INT, ADCVREF_EXT, ADCVREF_VDDA |
| void ADC_InitDual | ( | ADC12_Regs * | adc12, |
| uint32_t | channel1, | ||
| uint32_t | channel2, | ||
| uint32_t | reference | ||
| ) |
Initialize 12-bit ADC for two channels.
Initialize 12-bit ADC0 or ADC1 in software-triggered mode to take measurements when the associated function is called. Two channels are to be measured
| adc12 | is ADC0 or ADC1 |
| channel1 | is the 0 to 7 |
| channel2 | is the 0 to 7 |
| reference | is ADCVREF_INT, ADCVREF_EXT, ADCVREF_VDDA |
| void ADC_InitTriple | ( | ADC12_Regs * | adc12, |
| uint32_t | channel1, | ||
| uint32_t | channel2, | ||
| uint32_t | channel3, | ||
| uint32_t | reference | ||
| ) |
Initialize 12-bit ADC for three channels.
Initialize 12-bit ADC0 or ADC1 in software-triggered mode to take measurements when the associated function is called. three channels are to be measured
| adc12 | is ADC0 or ADC1 |
| channel1 | is the 0 to 7 |
| channel2 | is the 0 to 7 |
| channel3 | is the 0 to 7 |
| reference | is ADCVREF_INT, ADCVREF_EXT, ADCVREF_VDDA |
| void ADC_InTriple | ( | ADC12_Regs * | adc12, |
| uint32_t * | d1, | ||
| uint32_t * | d2, | ||
| uint32_t * | d3 | ||
| ) |
Trigger three ADC measurements and wait for results.
Trigger a triple ADC0 or ADC1 measurement, wait for it to complete, and return the three 12-bit results as 0 to 4095. The ADC input voltage range is 0 to 3.3V. Busy-wait synchronization used.
| adc12 | is ADC0 or ADC1 |
| *d1 | address into which the first ADC sample will be stored |
| *d2 | address into which the second ADC sample will be stored |
| *d3 | address into which the third ADC sample will be stored |