Teensy 3.6 PDB register access access causes program to crash

Status
Not open for further replies.

jenelson

New member
I am not sure what is going on here, but I am writing a program to interface a spectrometer CCD sensor using a Teensy 3.6.
I am able to get the integration timer, clocks, waveforms, interrupts, etc working perfectly. I even have the ADC setup and tested.

My plan was to trigger the ADC from FTM2 CH0 output via the PDB in bypass mode as a timed trigger. I started coding the PDB setup function, but whenever I touch any PDB register, the Teensy 3.6 just locks.

If I try any read or write to any PDB register, the program loop just stops running.
I tried every single PDB register with the same result - lock / FAIL.

Below is the problem to the simplest case.

The problem repeats with this simple program for me every time.

//*************** This Locks *********************

void setup() {
Serial.begin(9600);
}

void loop() {
uint32_t debug;
Serial.println(123);
debug=PDB0_SC; // this line locks the program
Serial.println(456);
}

The output is:

123...locks

//************* This runs *********************

Comment out the read PDB0_SC thusly:

void setup() {
Serial.begin(9600);
}

void loop() {
uint32_t debug;
Serial.println(123);
//debug=PDB0_SC; //comment out this line
Serial.println(456);
}

The output is:

123
456
123
456...and so on

//****************************************

Reading or writing to any PDB register causes a lockup regardless of value

I am running Arduino 1.8.10 / Teensyduino 1.4.8 / Windows 10

It looks like others are using the PDB successfully with Teensy 3.6, so I suspect its either something particular about my setup, or a very recent bug.

-tnx jim
 
You need to power-on the PDB before you can access it.

Thanks Frank!


SIM_SCGC6 |= SIM_SCGC6_PDB; //enable the PDB Clock Gate Control

This enables the clocks to the PDB module.
Once the SIM_SCGC6_PDB bit is set, I am able to access the PDB registers without crashing.

At least I didn't waste too much time on this.
 
Status
Not open for further replies.
Back
Top