Testing if DAC pins are working

Status
Not open for further replies.

Projectitis

Well-known member
Hi all,

I may have fried my DAC pins on T_3.6 (but I'm unsure how). I just stopped getting audio while debugging a project.
I've tried a very simple sketch (below) to see if they are working, but I read no voltage between the pin and AGND (either pin).
Is my sketch correct? Do I need to initialise the DAC pins first? Or is there another way to test for fried DAC pins?

Code:
void setup() {
  	// put your setup code here, to run once:
	analogWrite( 21, (uint32_t)(4095 * 1) );
	analogWrite( 22, (uint32_t)(4095 * 0.5) );
}

void loop() {
  // put your main code here, to run repeatedly:
	
}
 
Sorry, basic mistake. The pins aren't 21 and 22, they are A21 and A22!

Code:
void setup() {
  	// put your setup code here, to run once:
	analogWrite( A21, (uint32_t)(4095 * 1) );
	analogWrite( A22, (uint32_t)(4095 * 0.5) );
}

void loop() {
  // put your main code here, to run repeatedly:
	
}
 
Running on a 3.6 here the code points to digital pin21/22 not A21/22

try

Code:
void setup() {
    // put your setup code here, to run once:
  analogWrite( A21, (uint32_t)(4095 * 1) );
  analogWrite( A22, (uint32_t)(4095 * 0.5) );
}

void loop() {
  // put your main code here, to run repeatedly:
    analogWrite( A21, (uint32_t)(4095 * 1) );
  analogWrite( A22, (uint32_t)(4095 * 0.5) );
delay(500);
    analogWrite( A21, (uint32_t)(0) );
  analogWrite( A22, (uint32_t)(0) );
  
delay(500);
}
Edit - looks like you already found it -though I see the same upper value for A21 and A22 so looks like some integer math going on.
 
Thanks GremlinWrangler. Almost all of the DAC examples and threads I can find are specifically for the Audio shield, so finding relevant info is quite tricky!
 
Status
Not open for further replies.
Back
Top