I am trying to put a 38khx frequency on PD pin 3 of a Xmega128D3. I am using 32Mhz internal clock. The code is below. What I am doing wrong?
Thank you. I fixed that and I am still having some problem.In debug mode, the CNT is not changing.
You've set 1st bit of CTRLB, so it's in "FRQ" mode and TOP is done using CCA, NOT CCD. So, setup to use PD0 => OC0A of the TCD0 system.
Charles, what you wrote is correct, and so is what I wrote. It depends on the configuration. Look in Manual D, timer section for reg. description of CTRLB, "FRQ" bit, which you set. Then go read about the FRQ mode of WG in that section of the timers and tie the 2 sections info together to see what I mean ( Might as well find out about definiton of "TOP" too ). OC0A is the pin to to used with CCA ( see pinout & pin function section of the 'D3 PRELIMINARY datasheet ).
Edit: It looks like you can do one-stop shopping using avr1306 for all points!
Thank you for your input indianajones.
I read all these and I am still confused. I did get it to work to put out a 38khz on portD pin 3 but by trial and error I discovered that I need to set CCA register to 1. I have no idea why.
TCD0.CCAH = 0x01; //***	???***neeeded to work****????
Because you set the FRQ bit, so TOP is set by TCD0.CCA, NOT TCD0.CCD, like I told you before. Look at the reg. description for CTRLB. So it's involved in setting the output frequency. There's an eq'n. for what that freq. will be, didn't you see it?
match between the CNT and CCA registers as shown in Figure 12-12 on page 132.
Edit: Well, no mention of doing PWM in that mode, so I guess only CCA needs to be set. Try it w/o setting the CCD register and see what happens.