Using registers with Teensy 36

Status
Not open for further replies.

ossi

Well-known member
I am very new to the tensy36 board. I am trying to access CPU-registers directly.
Some code really works well. For example:
Code:
// show data direction including PIN13=LED pin
reg=GPIOC_PDDR ; Serial.printf("GPIOC_PDDR =%08XH\n",reg) ;
shows the right value. But there are other registers where I run into problems
Example:
Code:
// reg=DAC0_DAT0H ;  Error: DAC0_DAT0H was not declared in this scope

DAC0_DAT0L =0x12 ; Error: register is known but program seems to crash there (never reaches the folliwng line

 Serial.println("Hello World 4");

So the qustion is: Why is DAC0_DAT0H not known while DAC0_DAT0L is known?
What is the problem with DAC0_DAT0L =0x12 ; Is there an access-violation or similar?
If so how can I overcome that problem?
 
Man... Read the reference manual... By default and to save energy, many of the internal peripherals like the DAC are disabled by default and trying to access the corresponding registers leads to a hard fault.
While the Teensyduino core files and libraries take care of enabling the needed peripherals before using these, you have to do it “by hand” when you try a more bare metal approach by setting the corresponding bit(s) in the corresponding register(s) of the System Integration Module (SIM). For DAC0, it’s for example SIM_SCGC2 |= SIM_SCGC2_DAC0
 
Status
Not open for further replies.
Back
Top