EmbDev.net

Forum: µC & Digital Electronics Timer Counter example in AVR32 STUDIO


von Jack (Guest)


Rate this post
useful
not useful
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,
1
tc_waveform_opt_t waveform_opt =
in which the last line of the code is
1
.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

von priyanki v. (Company: MDH) (priyanki_23)


Rate this post
useful
not useful
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

von Jack J. (jackjill)


Rate this post
useful
not useful
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:
1
// Set the compare triggers.
2
  tc_write_ra(tc, EXAMPLE_TC_CHANNEL_ID, 0x0600);     // Set RA value.
3
  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.
1
// Set the compare triggers.
2
  tc_write_ra(tc, EXAMPLE_TC_CHANNEL_ID, 0x0500);     // Set RA value.
3
  tc_write_rc(tc, EXAMPLE_TC_CHANNEL_ID, 0x8500);     // Set RC value.

Hope this answers your question.
Regards,
Jack

von priyanki (Guest)


Rate this post
useful
not useful
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

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.