Hi
I can't get PWM(0) on my ECIOARM to work in 10bit it is still in 8bit resolution even when I use "SetDutyCycle10bit".
I have to increase SetDutyCycle10bit (INT) by 8 to get a change in pulse length. Is it suppose to be like this or am I missing something?
10bit duty cycle operates in 8bit FL4-ARM
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: 10bit duty cycle operates in 8bit FL4-ARM
Hello,
The 10-bit mode basically adds two bits to the least significant side of the PWM mark space ratio allowing for slightly more resolution.
The PWM period itself should not change. Is this what you are finding?
Edit: Sorry I thought you were using PIC. I'm currently not sure what happens for ARM I will have a dig in and see what I can find out for you.
The 10-bit mode basically adds two bits to the least significant side of the PWM mark space ratio allowing for slightly more resolution.
The PWM period itself should not change. Is this what you are finding?
Edit: Sorry I thought you were using PIC. I'm currently not sure what happens for ARM I will have a dig in and see what I can find out for you.
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
- 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: 10bit duty cycle operates in 8bit FL4-ARM
Hello again,
Right it looks like the ARM hardware only supports 8-bit PWM operation. The function simply takes the 10-bit value you pass in and shifts it down to 8-bits. I think the only reason the function is there is so we can import 10-bit PWM programs from PIC and AVR into ARM without error.
Right it looks like the ARM hardware only supports 8-bit PWM operation. The function simply takes the 10-bit value you pass in and shifts it down to 8-bits. I think the only reason the function is there is so we can import 10-bit PWM programs from PIC and AVR into ARM without error.
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
- 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: 10bit duty cycle operates in 8bit FL4-ARM
Right Last one.
It looks like the ARM does support up to 16-bit PWM so I was wrong about that.
The problem lies in changing the bit depth from 8 to 10 which would have the effect of changing the overall period on ARM which means the period value shown in the component properties would be incorrect for 10-bit operation. Maybe we can do something about this for v5.
How about using a timer interrupt for now and bit banging out the PWM. This way you can get any resolution you require.
There is an example of bit banged PWM available from here:
http://www.matrixmultimedia.com/article.php?a=52
It looks like the ARM does support up to 16-bit PWM so I was wrong about that.
The problem lies in changing the bit depth from 8 to 10 which would have the effect of changing the overall period on ARM which means the period value shown in the component properties would be incorrect for 10-bit operation. Maybe we can do something about this for v5.
How about using a timer interrupt for now and bit banging out the PWM. This way you can get any resolution you require.
There is an example of bit banged PWM available from here:
http://www.matrixmultimedia.com/article.php?a=52
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
- 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: 10bit duty cycle operates in 8bit FL4-ARM
Ok last post I promise.
One way to get 10-bit PWM working using the peripheral would be to use the custom code feature.
Edit the Enable function and change the following lines
AT91F_PWMC_CfgChannel(AT91C_BASE_PWMC, 0, 0x020b, %a, 2); // Set channel parameters
to
AT91F_PWMC_CfgChannel(AT91C_BASE_PWMC, 0, 0x020b, 1023, 2); // Set channel parameters
and
AT91F_PWMC_CfgChannel(AT91C_BASE_PWMC, 1, 0x020b, %a, 2); // Set channel parameters
to
AT91F_PWMC_CfgChannel(AT91C_BASE_PWMC, 1, 0x020b, 1023, 2); // Set channel parameters
Then edit the SetDutyCycle10bit function and change this following line.
nDuty = (nDuty >> 2) & 0xff;
to
//nDuty = (nDuty >> 2) & 0xff;
Let me know how you get on. As I say the period shown in the component properties will be incorrect but you should get 10-bit resolution.
One way to get 10-bit PWM working using the peripheral would be to use the custom code feature.
Edit the Enable function and change the following lines
AT91F_PWMC_CfgChannel(AT91C_BASE_PWMC, 0, 0x020b, %a, 2); // Set channel parameters
to
AT91F_PWMC_CfgChannel(AT91C_BASE_PWMC, 0, 0x020b, 1023, 2); // Set channel parameters
and
AT91F_PWMC_CfgChannel(AT91C_BASE_PWMC, 1, 0x020b, %a, 2); // Set channel parameters
to
AT91F_PWMC_CfgChannel(AT91C_BASE_PWMC, 1, 0x020b, 1023, 2); // Set channel parameters
Then edit the SetDutyCycle10bit function and change this following line.
nDuty = (nDuty >> 2) & 0xff;
to
//nDuty = (nDuty >> 2) & 0xff;
Let me know how you get on. As I say the period shown in the component properties will be incorrect but you should get 10-bit resolution.
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: 10bit duty cycle operates in 8bit FL4-ARM
Thanks it works, like you suggested in your last post.
I only had some permission issues with Win7 not allowing to change files in program files folder. Had to move the file to my desktop, make the changes, and move it back.
Not that I need it, but would it be possible to use 16bit resolution?
I only had some permission issues with Win7 not allowing to change files in program files folder. Had to move the file to my desktop, make the changes, and move it back.
Not that I need it, but would it be possible to use 16bit resolution?
Jeppe
Don't say oups!? Say Interesting!
Don't say oups!? Say Interesting!
- 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: 10bit duty cycle operates in 8bit FL4-ARM
Hello,
16-bit resolution is possible by changing the code like this.
AT91F_PWMC_CfgChannel(AT91C_BASE_PWMC, 0, 0x020b, 65535, 2); // Set channel parameters
AT91F_PWMC_CfgChannel(AT91C_BASE_PWMC, 1, 0x020b, 65535, 2); // Set channel parameters
This line also still needs to be commented out.
//nDuty = (nDuty >> 2) & 0xff;
You should then be able to pass in a 16-bit value from Flowcode using the function as is. Beware about signed / unsigned maths in Flowcode using INT variables. I don't think this should be an issue for this but just something to be aware of if things do start acting strange.
As the resolution is now 16-bit the overall period will be 6/8-bits larger giving you an even lower overall PWM frequency.
16-bit resolution is possible by changing the code like this.
AT91F_PWMC_CfgChannel(AT91C_BASE_PWMC, 0, 0x020b, 65535, 2); // Set channel parameters
AT91F_PWMC_CfgChannel(AT91C_BASE_PWMC, 1, 0x020b, 65535, 2); // Set channel parameters
This line also still needs to be commented out.
//nDuty = (nDuty >> 2) & 0xff;
You should then be able to pass in a 16-bit value from Flowcode using the function as is. Beware about signed / unsigned maths in Flowcode using INT variables. I don't think this should be an issue for this but just something to be aware of if things do start acting strange.
As the resolution is now 16-bit the overall period will be 6/8-bits larger giving you an even lower overall PWM frequency.
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