EmbDev.net

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


Author: Jack (Guest)
Posted on:

Rate this post
0 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,
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

Author: priyanki vashi (Company: MDH) (priyanki_23)
Posted on:

Rate this post
0 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

Author: Jack Jill (jackjill)
Posted on:

Rate this post
0 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:
// 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

Author: priyanki (Guest)
Posted on:

Rate this post
0 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

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.