Software ADC on Teensy 3.1

Status
Not open for further replies.

Borja

Active member
Hi everybody,

I'm trying to use the ADC0 triggering by software. I read the data sheet and I understood if I write in the SC1A register which pin want to use, the conversion starts. Is that correct? I want to use the Pin 16 of Teensy and according to the manual is the channel ADC0_SE8 and the bits for the bits 0-4 in ADC0_SC1A are: 01000.


//Pin16 Teensy
ADC0_SC1A &= ~(1<<4);
ADC0_SC1A |= (1<<3);
ADC0_SC1A &= ~(1<<2);
ADC0_SC1A &= ~(1<<1);
ADC0_SC1A &= ~(1<<0);

Above is my setup:


ADC0_SC1A &= ~(1<<5); //No diff
ADC0_SC1A &= ~(1<<6); //Disable int.

ADC0_SC2 =0x00; //Flag = 0

ADC0_CFG1 &= ~(1<<7); //Mode normal
ADC0_CFG1 &= ~(1<<6); //Clock
ADC0_CFG1 &= ~(1<<5);
ADC0_CFG1 |= (1<<4); //Long time sampling
ADC0_CFG1 |= (1<<3); // Conversion 10bits
ADC0_CFG1 &= ~(1<<2);
ADC0_CFG1 &= ~(1<<1); //Bus Clock
ADC0_CFG1 &= ~(1<<0);

ADC0_CFG2 &= ~(1<<4); //ADC channels A
ADC0_CFG2 &= ~(1<<3); //No asynchronous
ADC0_CFG2 &= ~(1<<2); //Conversion normal
ADC0_CFG2 &= ~(1<<1); //Max. time
ADC0_CFG2 &= ~(1<<0);


ADC0_SC3 |= (1<<7); //Calibration
 
Status
Not open for further replies.
Back
Top