Hello there! I am working with an EVK1100 board using the IDE AVR32 Studio from Atmel. I am trying to change the output frequency of the signal generated by the microcontroller while using the example program "Timer Counter (TC) example 1". I have been able to modify the program so as to get a duty cycle of 50% and I have also changed the clock to external OSC with 12Mhz. The problem is that there is a function called,
tc_waveform_opt_t waveform_opt =
in which the last line of the code is
.tcclks = TC_CLOCK_SOURCE_TC3
This line is dividing my clock by 3. I need to remove this division of frequency completely. But the minimum it allows is divide by 2 (TC_CLOCK_SOURCE_TC2). How do I get my signal with the same frequency as the given clock (12 MHz)? Any help will be deeply appreciated. Regards, Jack
Hello Jack , I am interested to see the code you have to generate 50& duty cycle. Is it possible to share for you ? Thanks // Priyanki
priyanki vashi wrote: > Hello Jack , > > I am interested to see the code you have to generate 50& duty cycle. > Is it possible to share for you ? > > Thanks // Priyanki Hi, You can simply modify this following code:
// Set the compare triggers. tc_write_ra(tc, EXAMPLE_TC_CHANNEL_ID, 0x0600); // Set RA value. tc_write_rc(tc, EXAMPLE_TC_CHANNEL_ID, 0x2000); // Set RC value.
Here just change the values of RA and RC to get the required duty cycle. If you use the same values for RA and RC you will get the same duty cycle but then the frequency will be divided by half. To keep the frequency intact, the value of RC should be much much higher. Try the following code to get 50% duty cycle with the same frequency.
// Set the compare triggers. tc_write_ra(tc, EXAMPLE_TC_CHANNEL_ID, 0x0500); // Set RA value. tc_write_rc(tc, EXAMPLE_TC_CHANNEL_ID, 0x8500); // Set RC value.
Hope this answers your question. Regards, Jack
Hi , Thanks for reply. We now followed a different method to get waveforms. It's a table driven approach with Enable & DIR pins & hence driving the stepper motor. But after trying this approach , I would try the timer method & check. Regards,P