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

Moderator: Benj

Post Reply
Lagoda
Posts: 170
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 69 times
Been thanked: 61 times
Contact:

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

Post by Lagoda »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

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

Post by Benj »

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.

Lagoda
Posts: 170
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 69 times
Been thanked: 61 times
Contact:

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

Post by Lagoda »

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.57 KiB) Downloaded 210 times

User avatar
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: The PIC16F15344 PWM component can only be set to 8-bit mode.

Post by Benj »

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.

Lagoda
Posts: 170
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 69 times
Been thanked: 61 times
Contact:

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

Post by Lagoda »

Hi Ben,

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

Lagoda

Lagoda
Posts: 170
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 69 times
Been thanked: 61 times
Contact:

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

Post by Lagoda »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

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

Post by Benj »

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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

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

Post by Benj »

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>

Lagoda
Posts: 170
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 69 times
Been thanked: 61 times
Contact:

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

Post by Lagoda »

Hi Ben,

In my C file, this line looks like this:

#define MX_PWM_NEW_TMR_CONF

(If I overwrite CONF2 then it works. :) )

User avatar
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: The PIC16F15344 PWM component can only be set to 8-bit mode.

Post by Benj »

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: 170
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 69 times
Been thanked: 61 times
Contact:

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

Post by Lagoda »

Hi,

This version works for me.
Flowcode_ver.jpg
Flowcode_ver.jpg (44.36 KiB) Viewed 6182 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: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

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

Post by Benj »

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: 170
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 69 times
Been thanked: 61 times
Contact:

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

Post by Lagoda »

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: 170
Joined: Fri Jul 15, 2016 9:51 pm
Has thanked: 69 times
Been thanked: 61 times
Contact:

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

Post by Lagoda »

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

User avatar
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: The PIC16F15344 PWM component can only be set to 8-bit mode.

Post by Benj »

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.

Post Reply