Page 1 of 1

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

Posted: Sun Feb 17, 2019 8:19 pm
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

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

Posted: Mon Feb 18, 2019 10:26 pm
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.

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

Posted: Tue Feb 19, 2019 12:53 pm
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

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

Posted: Tue Feb 19, 2019 5:42 pm
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.

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

Posted: Tue Feb 19, 2019 6:01 pm
by Lagoda
Hi Ben,

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

Lagoda

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

Posted: Wed Feb 20, 2019 8:48 pm
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

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

Posted: Thu Feb 21, 2019 10:57 am
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.

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

Posted: Thu Feb 21, 2019 11:05 am
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>

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

Posted: Thu Feb 21, 2019 12:17 pm
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. :) )

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

Posted: Thu Feb 21, 2019 12:39 pm
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/

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

Posted: Thu Feb 21, 2019 1:49 pm
by Lagoda
Hi,

This version works for me.
Flowcode_ver.jpg
Flowcode_ver.jpg (44.36 KiB) Viewed 6185 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:

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

Posted: Thu Feb 21, 2019 1:57 pm
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.

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

Posted: Thu Feb 21, 2019 2:11 pm
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?

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

Posted: Fri Feb 22, 2019 1:39 pm
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

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

Posted: Fri Feb 22, 2019 5:53 pm
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.