wonderways
New member
I'm trying to code the DACs in the Teensy 3.6 to a synthesizer.
The problem is that when I write in any of the registers to control the DAC module, the Teensy just stops responding!
Does anyone know if it is needed to initialize something before accessing the registers?
The example code is below:
Thancks in advance
The problem is that when I write in any of the registers to control the DAC module, the Teensy just stops responding!
Does anyone know if it is needed to initialize something before accessing the registers?
The example code is below:
Code:
[INDENT]void setDACPos(byte pos){
DAC0_C2 = (pos << 4 )| 15 ;
}
generateDacBuffer();
void setup() {
DAC0_DAT0L = 0;
Serial.println("asdasd");
generateDacBuffer();
setDACPos(0);
DAC0_C1 = 1 | 1 <<6;
DAC0_C0 = 1<<6 | 1 << 5 | 1 << 4;
}
int counter = 0;
void loop() {
setDACPos(counter); // selects the value to output from the buffer at counter
position
counter++;
if(counter == 16){
counter = 0;
}
delay (1000);
}
void generateDacBuffer(){
short deltaValue = 100;
short startValue= 200;
short* regs =(short*) 0x400CC000; // adress to the first buffer register =
DAC0_DAT0L
// also craches if i use variable DAC0_DAT0L
short value = startValue;
for(int i = 0; i < 16; i++){
// crashes below
*regs = holder;// also craches if i use variable DAC0_DAT0L . example : DAC0_DAT0L = 255;
value += deltaValue;
regs++;
}
}
[/INDENT]
Thancks in advance
Last edited by a moderator: