PIC18F47J53 - PWM (CCP) configuration

An area to discuss 8-bit PIC specific problems and examples

Moderator: Benj

Post Reply
streammaster
Posts: 78
Joined: Mon Jul 31, 2017 11:14 am
Has thanked: 7 times
Been thanked: 13 times
Contact:

PIC18F47J53 - PWM (CCP) configuration

Post by streammaster »

Hi Guys,
I'm trying to utilize 18F47J53 (E)PWM hardware resources, but i do not know how to do it by using the Flowcode 7. I suspect that the configuration file for this device is not 100%?

For start the PWM can use timer 2, Timer 4, Timer 6 or Timer 8. The configuration in Flowcode is locked to Timer2 only.
Another issue is that channels 1 -3 supposed to be Enhanced PWM (here is the text from the data sheet):.
"The EPWM outputs are multiplexed with I/O pins and are designated: PxA, PxB, PxC and PxD. The polarity of the PWM pins is configurable and is selected by setting the CCPxM bits in the CCPxCON register appropriately".
Is this implemented in the Flowcode?
How i can configure Half-Bridge mode and configure "Dead-Band Delay"?

How i should use this EPWM with Flow code? I would appreciate any guidance on this.

Regards,

Igor

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: PIC18F47J53 - PWM (CCP) configuration

Post by Benj »

Hello Igor,
For start the PWM can use timer 2, Timer 4, Timer 6 or Timer 8. The configuration in Flowcode is locked to Timer2 only.
The J53 devices have a very complex timer configuration where some channels have more options than others. So as all channels have timer 2 available as the default this is all that we have provided. You could manually change the timer for a PWM channel by writing to the CCPTMRS1 or CCPTMRS2 registers using a C code icon.
Another issue is that channels 1 -3 supposed to be Enhanced PWM (here is the text from the data sheet):.
How i can configure Half-Bridge mode and configure "Dead-Band Delay"?
We don't support the enhanced PWM functionality, there are just too many variations of this from device to device to effectively support and make useful. For this the easiest way is for you to manipulate the registers using C code icons. Once you have this working you could make a component from your working code fairly easily.

streammaster
Posts: 78
Joined: Mon Jul 31, 2017 11:14 am
Has thanked: 7 times
Been thanked: 13 times
Contact:

Re: PIC18F47J53 - PWM (CCP) configuration

Post by streammaster »

Thank you Ben,

I will try, but i most likely would need help with configuring the registers using C code icon (having correct syntax in it).

I will need to configure following registers:

TRISp (Pin configuration, 8 bit)
CCPxCON - (ECCP 1,2,3 control, 8 bit)
ECCPxDEL - (ECCP1/2/3 ENHANCED PWM CONTROL, 8 bit)
ECCPxAS - (ECCP1/2/3 AUTO-SHUTDOWN CONTROL, 8 bit)
CCPTMRS0 (ECCP 1,2,3 Timer selection, 8 bit)
PSTRxCON - (PULSE STEERING CONTROL, 8 bit)
CCPRxL - (Duty Cycle Registers, 8 bit)
CCPRxH - (Duty Cycle Registers, 8 bit)
TxCON - (Timer configuration , 8 bit)
PRx - (Timer period register, 8 bit)

Could you please help me with an example of configuring those registers by using C code icon? Do it for ECCP module 1, Timer 2.
Once the syntax is working i will get actual configuration values from the datasheet.
You mentioned i could create my own component after I got this working. I will need help to create the simulation part of that component to be complete and working correctly in Flowcode simulation.


I'm looking forward to get this little project on the way and solved! I'm sure it will be good help and learning curve for everyone else who is needing to implement 'special' features in Flowcode.

Regards,

Igor

streammaster
Posts: 78
Joined: Mon Jul 31, 2017 11:14 am
Has thanked: 7 times
Been thanked: 13 times
Contact:

Re: PIC18F47J53 - PWM (CCP) configuration

Post by streammaster »

Here is an update,

It looks that everything is quite straight forward apart of the configuring 'Configurable ports' I never did this and reading the Datasheet there is some assembly example (for UART) which i reused here, but not sure if this is correct.

I made some progress but i failed on implementing the assembler inside the C. I'm getting a syntax error.
Any idea what i did wrong.
PIC18F4XJ5X Demo board Igors EPWM.fcfx
(12.35 KiB) Downloaded 234 times
Thanks,

Igor

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: PIC18F47J53 - PWM (CCP) configuration

Post by Benj »

Hi Igor,

Glad you're making progress, No need for the assembler code or the unlock sequence as you have this disabled in your configuration anyway.

You can simply replace the assembler code with this.

Code: Select all

RPOR9 = 0x0E;
RPOR10 = 0x0F;

Post Reply