Page 1 of 1
PIC18F47J53 - PWM (CCP) configuration
Posted: Tue Jan 23, 2018 9:49 am
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
Re: PIC18F47J53 - PWM (CCP) configuration
Posted: Tue Jan 23, 2018 1:20 pm
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.
Re: PIC18F47J53 - PWM (CCP) configuration
Posted: Thu Jan 25, 2018 2:21 am
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
Re: PIC18F47J53 - PWM (CCP) configuration
Posted: Thu Jan 25, 2018 8:04 am
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.
Thanks,
Igor
Re: PIC18F47J53 - PWM (CCP) configuration
Posted: Fri Jan 26, 2018 11:28 am
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.