PWM 18F27K40
Moderator: Benj
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
PWM 18F27K40
Clock frequency confirmed by 10Hz test as being 48MHz.
the delay is exactly 100ms,
Required PWM frequency = 10KHz
PWM properties: Measured PWM frequency = 375Hz
the delay is exactly 100ms,
Required PWM frequency = 10KHz
PWM properties: Measured PWM frequency = 375Hz
Martin
- 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: PWM 18F27K40
Thanks for letting u sknow Martin,
Been EMC testing all morning and what with the heat I can't focus on this at the moment. I started and failed
I'll try and make this a priority to solve for you. Probably something to do with assuming 8/10 bit PWM but actually it's 16-bit.
Been EMC testing all morning and what with the heat I can't focus on this at the moment. I started and failed
I'll try and make this a priority to solve for you. Probably something to do with assuming 8/10 bit PWM but actually it's 16-bit.
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
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: PWM 18F27K40
I can understand that, at least rain has help to cool things down?Benj wrote:what with the heat I can't focus on this at the moment
That's brilliant!Benj wrote:'ll try and make this a priority to solve for you.
Thank you Ben.
Martin
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
- 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: PWM 18F27K40
Hi Martin,
I've looked a few times, this family seems to be breaking rules all over the place. I'll keep on with it
I've looked a few times, this family seems to be breaking rules all over the place. I'll keep on with it
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
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: PWM 18F27K40
Hi Ben,
Just noticed something after starting a new test Flowchart.
The PWM does not work at all until I added a timer2 interrupt!
After adding the interrupt, PWM will then run at the wrong frequency.
So it's getting the values from timer2 interrupt.
How strange.
Edit: Changed timer 2 Prescaler rate to 1 and the PWM went from 375Hz to 47.25KHz
This may help to shed some light on it?
PWM is set for timer 4
Just noticed something after starting a new test Flowchart.
The PWM does not work at all until I added a timer2 interrupt!
After adding the interrupt, PWM will then run at the wrong frequency.
So it's getting the values from timer2 interrupt.
How strange.
Edit: Changed timer 2 Prescaler rate to 1 and the PWM went from 375Hz to 47.25KHz
This may help to shed some light on it?
PWM is set for timer 4
Martin
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: PWM 18F27K40
In addition to the above post.
PWM will only work if select PWM timer for Timer 4 (Tried with timers 2 & 6 which does not work).
The PWM will work at the correct frequency if Timer2 interrupt Prescale Rate is set to the required PWM Prescale.
Timer 2 interrupt Rollover Value is set to the required PWM period.
The timer 2 interrupt can be enabled, then disabled straight away.
PWM will still function correctly.
Note:
If timer2 Postscaler Rate is left on 1:1 then the Interrupt Frequency displayed will be the PWM frequency.
Hope this helps anyone with PIC18FXXK40 who requires PWM
PWM will only work if select PWM timer for Timer 4 (Tried with timers 2 & 6 which does not work).
The PWM will work at the correct frequency if Timer2 interrupt Prescale Rate is set to the required PWM Prescale.
Timer 2 interrupt Rollover Value is set to the required PWM period.
The timer 2 interrupt can be enabled, then disabled straight away.
PWM will still function correctly.
Note:
If timer2 Postscaler Rate is left on 1:1 then the Interrupt Frequency displayed will be the PWM frequency.
Hope this helps anyone with PIC18FXXK40 who requires PWM
Martin
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
- 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: PWM 18F27K40
Hi Martin,
I've had another look into the problem this morning and pushed a change to the device definition files which hopefully solves the problem.
Thanks for chasing this one up.
I've had another look into the problem this morning and pushed a change to the device definition files which hopefully solves the problem.
Thanks for chasing this one up.
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
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: PWM 18F27K40
Hi Ben,
Sorry, still the same after updating with new fcdx file.
PWM does not work until timer2 interrupt set up as described in my above post.
Sorry, still the same after updating with new fcdx file.
PWM does not work until timer2 interrupt set up as described in my above post.
Martin
- 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: PWM 18F27K40
Hi Martin,
Wow thanks for getting back so fast. I beleive I have now found and fixed the problem for you.
Wow thanks for getting back so fast. I beleive I have now found and fixed the problem 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
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: PWM 18F27K40
Hi Ben,
I'm afraid the latest version cases the following error:
You're welcome.Benj wrote:Wow thanks for getting back so fast.
I'm afraid the latest version cases the following error:
Build date: Nov 15 2017
Part Support Version: 1.45
Copyright (C) 2017 Microchip Technology Inc.
License type: Node Configuration
MX_PWM_ALTTIMER: 748: (1500) invalid token in #if expression
(908) exit status = 1
(908) exit status = 1
Error returned from [xc8.exe]
C:\Program Files (x86)\Flowcode\Compilers\pic\batch\pic_xc8_comp.bat reported error code 1
Autoclose turned off
FINISHED
Martin
- 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: PWM 18F27K40
Thanks Martin,
Third time's the charm (hopefully)
Third time's the charm (hopefully)
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
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
- 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: PWM 18F27K40
Woohoo,
Excellent, sorry this was so long in getting to you and really happy this is working correctly now.
Thanks for bearing with and letting me know.
Excellent, sorry this was so long in getting to you and really happy this is working correctly now.
Thanks for bearing with and letting me know.
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