Skip to content

Trouble generating a 15-20KHz PWM signal on PA3 of an ATTiny404 #741

Answered by SpenceKonde
NickLD asked this question in Q&A
Discussion options

You must be logged in to vote

Most of what you want is already set up. There's just a small tweak you need to do (unnecessary steps commented out

//takeOverTCA0(); // this is needed if you change the portmux, or run in SINGLE mode, but not split mode on the default pins, 
//TCA0.SPLIT.CTRLD = 1; //Needed only if you had to take over the timer
//TCA0.SPLIT.HPER = 254; // Not 255 if using analog write! You want 256 levels of pwm, right? And 100% on and 0% on should be one of those. calling analogWrite(pin,0) or analogWrite(pin,255) is caught and calls digitalWrite on the pin, If you have the period at 255, there are 256 timer ticks per cycle, but 257 possible duty cycles including 100% and 0%.. I forget which end the di…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@NickLD
Comment options

@NickLD
Comment options

Comment options

You must be logged in to vote
1 reply
@mechatroniks-git
Comment options

Comment options

You must be logged in to vote
1 reply
@NickLD
Comment options

Answer selected by NickLD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants