The PIC16F15344 PWM component can only be set to 8-bit mode.

Moderator: Benj

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

The PIC16F15344 PWM component can only be set to 8-bit mode.

Postby Lagoda » Sun Feb 17, 2019 8:19 pm

Hi Ben,

I would like to use the PWM periphery of the PIC16F15344 MCU in 10-bits mode.
The PWM component macro only supports 8-bits mode.
Is it possible to upgrade to 10 bits?

Thank you in advance,

Lagoda

User avatar
Benj
Matrix Staff
Posts: 14797
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4759 times
Been thanked: 4361 times
Contact:

Re: The PIC16F15344 PWM component can only be set to 8-bit mode.

Postby Benj » Mon Feb 18, 2019 10:26 pm

Hi Lagoda,

If you use the SetDutyCycle10Bit macro this should hopefully allow a 10-bit value 0-1023 to be accepted. Let me know if it's not working on hardware.
These users thanked the author Benj for the post:
Lagoda (Tue Feb 19, 2019 12:44 pm)
Rating: 5%
 

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: The PIC16F15344 PWM component can only be set to 8-bit mode.

Postby Lagoda » Tue Feb 19, 2019 12:53 pm

Hi Ben,

Thanks for the quick response.

I forgot about this option. :oops:

I tried the PWM macro with a PIC16F15324 MCU on a CURIOSITY board.
The PWM output is not working. :(
I also tried it with 8 Bit resolution, but it doesn't do anything.

What I have noticed is that the PWM macro offers 6 channels for use, but the MCU has only 4 channels.

Would you do to investigate what's wrong?

Lagoda
Attachments
PWM_test_8Bit_16F15324.fcfx
(9.58 KiB) Downloaded 58 times

User avatar
Benj
Matrix Staff
Posts: 14797
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4759 times
Been thanked: 4361 times
Contact:

Re: The PIC16F15344 PWM component can only be set to 8-bit mode.

Postby Benj » Tue Feb 19, 2019 5:42 pm

Hi Lagoda,

Have you tried channels 1 and 3? Channels 1-2 are CCP based outputs. Channels 3-6 are PWM based outputs, hence 6 available PWM type outputs.
These users thanked the author Benj for the post:
Lagoda (Tue Feb 19, 2019 6:03 pm)
Rating: 5%
 

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: The PIC16F15344 PWM component can only be set to 8-bit mode.

Postby Lagoda » Tue Feb 19, 2019 6:01 pm

Hi Ben,

I also tried Channel 3 and Channel 4, but they don't work either.

Lagoda
These users thanked the author Lagoda for the post:
Benj (Tue Feb 19, 2019 6:32 pm)
Rating: 5%
 

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: The PIC16F15344 PWM component can only be set to 8-bit mode.

Postby Lagoda » Wed Feb 20, 2019 8:48 pm

Hi Ben,

I found something.

The content of the T2CLKCON register is 0x00 so the selection of the clock source is incorrect (T2CKIPPS)
If I write 0x01 (Fosc / 4) into this register, the PWM signal appears on the selected port.
I only checked the proportions of the waveform with an old oscilloscope, but it looks good.

I hope this will help you in the repair.

Best Regards,

Lagoda

User avatar
Benj
Matrix Staff
Posts: 14797
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4759 times
Been thanked: 4361 times
Contact:

Re: The PIC16F15344 PWM component can only be set to 8-bit mode.

Postby Benj » Thu Feb 21, 2019 10:57 am

Hi Lagoda,

Brilliant that's great glad you have it solved and many thanks for letting us know.

I'm making a fix for the issue now and will roll it out to the update system tomorrow.

User avatar
Benj
Matrix Staff
Posts: 14797
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4759 times
Been thanked: 4361 times
Contact:

Re: The PIC16F15344 PWM component can only be set to 8-bit mode.

Postby Benj » Thu Feb 21, 2019 11:05 am

Hi Lagoda,

Are you running 8.1 with the latest updates.

I've looked at the code and just found this.

Code: Select all

            #ifdef MX_PWM_NEW_TMR_CONF2
               T2CLKCON = 1;             //FOSC/4
            #endif


Looking at the 16F15344 device definition and the MX_PWM_NEW_TMR_CONF2 is being defined correctly?

You can check this by viewing the C code in Flowcode and right near the top should be this.

Code: Select all

#define MX_PIC

#define MX_CAL_PIC

#define MX_CLK_SPEED 19660800

#define FCP_NULL Unconnected_Port

#define MX_PWM_NEW_TMR_CONF2
#include <xc.h>
#include <math.h>
These users thanked the author Benj for the post:
Lagoda (Fri Feb 22, 2019 1:07 pm)
Rating: 5%
 

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: The PIC16F15344 PWM component can only be set to 8-bit mode.

Postby Lagoda » Thu Feb 21, 2019 12:17 pm

Hi Ben,

In my C file, this line looks like this:

#define MX_PWM_NEW_TMR_CONF

(If I overwrite CONF2 then it works. :) )
These users thanked the author Lagoda for the post:
Benj (Thu Feb 21, 2019 12:37 pm)
Rating: 5%
 

User avatar
Benj
Matrix Staff
Posts: 14797
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4759 times
Been thanked: 4361 times
Contact:

Re: The PIC16F15344 PWM component can only be set to 8-bit mode.

Postby Benj » Thu Feb 21, 2019 12:39 pm

Hmm, Are you running 8.1 with the latest updates? Maybe it's an old bug that's been fixed :wink:

You can get 8.1 from here.
https://www.matrixtsl.com/flowcode/download/

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: The PIC16F15344 PWM component can only be set to 8-bit mode.

Postby Lagoda » Thu Feb 21, 2019 1:49 pm

Hi,

This version works for me.
Flowcode_ver.jpg
Flowcode_ver.jpg (44.37 KiB) Viewed 2342 times

Before testing, I updated the Flowcode program.
It is also installed on multiple computers and each has a faulty result.
I did not modify the files that are part of Flowcode. :cry:

User avatar
Benj
Matrix Staff
Posts: 14797
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4759 times
Been thanked: 4361 times
Contact:

Re: The PIC16F15344 PWM component can only be set to 8-bit mode.

Postby Benj » Thu Feb 21, 2019 1:57 pm

Hi Lagoda,

Ok that looks like the latest version. If you open a project and then click on Help -> Check for updates then this should show you any files used in your project with fixes or improvements.

If you change the "Files in use" at the bottom of the window to "full database" then this will show you the latest of everything.

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: The PIC16F15344 PWM component can only be set to 8-bit mode.

Postby Lagoda » Thu Feb 21, 2019 2:11 pm

OK.
I used the "Full database" option and now I have a fresh and crisp Flowcode program.
And I restarted it after updating. :wink:
The result is the same as before.

Are you getting a flawless C file from the file (PWM_test_8Bit_16F15324.fcfx) I attached?

Lagoda
Posts: 153
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 66 times
Been thanked: 60 times
Contact:

Re: The PIC16F15344 PWM component can only be set to 8-bit mode.

Postby Lagoda » Fri Feb 22, 2019 1:39 pm

Hello Ben,


I think you have quite a lot of parallel tasks now.
Fixing this problem is not urgent for me, because I manually fix the wrong part in the C file and it will work. (I already know what to change. :D )

Thanks for the help.
Have a nice weekend!

Lagoda
These users thanked the author Lagoda for the post:
Benj (Fri Feb 22, 2019 5:51 pm)
Rating: 5%
 

User avatar
Benj
Matrix Staff
Posts: 14797
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4759 times
Been thanked: 4361 times
Contact:

Re: The PIC16F15344 PWM component can only be set to 8-bit mode.

Postby Benj » Fri Feb 22, 2019 5:53 pm

Hi Lagoda,

I think you have quite a lot of parallel tasks now.


Yes one or two on the go, support is not one of the main ones :wink:

I went through the definitions again this morning and checked that all the 16(L)F153xx family had the correct PWM definition. Most were ok but a couple were incorrect so these have now been sorted.

Fixing this problem is not urgent for me, because I manually fix the wrong part in the C file and it will work. (I already know what to change. :D )


Hopefully a new update will solve the issue but yes it's nice to have a workaround so you're not waiting on me.

Hope you have a good weekend too.
These users thanked the author Benj for the post:
Lagoda (Fri Feb 22, 2019 6:44 pm)
Rating: 5%