Hi All, my first post!
I am trying to work out how to implement the 'fast PWM' mode available on a number of the AVR devices. Is there functionality in FC 7 to do this with a macro or will it have to be done through a 'C' block? I have found the following application note http://www.atmel.com/Images/Atmel-2542- ... AVR131.pdf on the subject but as I rely on Flowcode to do the hard stuff I am struggling to work out what I would have to do to implement fast PWM within my project.
Can any one help me figure it out?
Many Thanks,
Matt
AVR Fast PWM programming
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: AVR Fast PWM programming
Hi Matt,
There is a PWM component under the Outputs component category that should be able to generate the high frequency PWM you need. Changing the Prescaler property to a low value should give you a fast PWM period.
Let us know how your getting on.
There is a PWM component under the Outputs component category that should be able to generate the high frequency PWM you need. Changing the Prescaler property to a low value should give you a fast PWM period.
Let us know how your getting on.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: AVR Fast PWM programming
Hi Ben, thanks for your reply.
The AVR's have two types of PWM, the standard seems to be available using the FC PWM component but the fast/high speed PWM does not. From the application note I gather the timer for the fast PWM can be set to a higher frequency than the CPU clock, up to 64MHz if properly configured.
How can I reconfigure the PWM timer to give me a base frequency in excess of the CPU clock frequency?
Cheers,
Matt
The AVR's have two types of PWM, the standard seems to be available using the FC PWM component but the fast/high speed PWM does not. From the application note I gather the timer for the fast PWM can be set to a higher frequency than the CPU clock, up to 64MHz if properly configured.
How can I reconfigure the PWM timer to give me a base frequency in excess of the CPU clock frequency?
Cheers,
Matt
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: AVR Fast PWM programming
Hi Matt,
Aha I see now, here is something you can try.
Enable the high speed PLL by using the C code.
Then wait for the PLL to lock with the following C code.
Finally switch on the asynchronous PWM mode with the following C code.
Then hopefully just use the PWM as you would normally and the hardware should output using the high frequency PWM.
Aha I see now, here is something you can try.
Enable the high speed PLL by using the C code.
Code: Select all
PLLCSR = 0x02;
Code: Select all
while ((PLLCSR & 1) != 1);
Code: Select all
PLLCSR = 0x06;
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Re: AVR Fast PWM programming
Hi Ben,
Thank you for the code, it has taken me a very long time to get round to trying it (I have been distracted with other projects).
I have given it a go and the complier has come back with an error ('PLLCSR' undeclared). I assume a library has to be included??
I have found another step by step example of someone using the 'fast PWM', but I am lost as how to convert this information into something usable for Flowcode.
http://www.re-innovation.co.uk/web12/in ... n-attiny85
Any help would be much appreciated.
Regards,
Matt
Thank you for the code, it has taken me a very long time to get round to trying it (I have been distracted with other projects).
I have given it a go and the complier has come back with an error ('PLLCSR' undeclared). I assume a library has to be included??
I have found another step by step example of someone using the 'fast PWM', but I am lost as how to convert this information into something usable for Flowcode.
http://www.re-innovation.co.uk/web12/in ... n-attiny85
Any help would be much appreciated.
Regards,
Matt
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: AVR Fast PWM programming
Hi Matt,
Is it the ATTiny85 device you're using?
PLLSCR is a register name so it sounds like it either doesn't exist on your device or has a different name.
Is it the ATTiny85 device you're using?
PLLSCR is a register name so it sounds like it either doesn't exist on your device or has a different name.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel