PWM alternative PIN on PIC18

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
JG1
Posts: 20
Joined: Sat Jul 11, 2009 5:00 pm

PWM alternative PIN on PIC18

Post by JG1 »

FlowcodeV4 and Proteus files
Flowcode.zip
Hello
I have a problem on using "alternative pin" with CCP2 PWM on PIC18F4455 (pin 36). The simulation with Flowcode (V4) is OK but it doesn't work on my hardware and with Proteus.
On using normal PIN (pin 16) there is no problem.
It seems that the problem is the same with other PIC's 18F.
Files are attached to verify this.

Thanks on advance

JG1
Posts: 20
Joined: Sat Jul 11, 2009 5:00 pm

Re: PWM alternative PIN on PIC18

Post by JG1 »

Sorry but the files are not accessible in the previous topic
Attachments
Flowcode.zip
(39.09 KiB) Downloaded 335 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: PWM alternative PIN on PIC18

Post by Benj »

Hello

As well as setting the alternative PWM pin in the PWM component properties you also have to use the use alt PWM pin in the chip's configuration to allow the alternative pin to be enabled.
config.JPG
config.JPG (84.5 KiB) Viewed 9153 times
Let me know if you are still having problems and I will look into this for you.

JG1
Posts: 20
Joined: Sat Jul 11, 2009 5:00 pm

Re: PWM alternative PIN on PIC18

Post by JG1 »

Hello

Thank you Benj for your help.
The problem is solved with PIC18F4455, but normally I use an ECIO circuit and for this "object" the parameters are not accessible, so it's impossible to configure like your indications.
Have you a solution for ECIO ?

Best regards

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: PWM alternative PIN on PIC18

Post by Benj »

Hello

Ok to change the ECIO config presets you can go into the Flowcode v4/FCD/ECIO40.FCD file using a text editor and edit the following lines.

This is the default configuration.

[Config]
0=0x20
1=0x0E
2=0x3E
3=0x1E
4=0x00
5=0x81
6=0x81
7=0x00
8=0x0F
9=0x80
10=0x0F
11=0xA0
12=0x0F
13=0x00

This is the configuration for the alternate CCP pin.

[Config]
0=0x20
1=0x0E
2=0x3E
3=0x1E
4=0x00
5=0x80
6=0x81
7=0x00
8=0x0F
9=0x80
10=0x0F
11=0xA0
12=0x0F
13=0x00

After you have edited the file be sure to restart Flowcode to load the changes.

JG1
Posts: 20
Joined: Sat Jul 11, 2009 5:00 pm

Re: PWM alternative PIN on PIC18

Post by JG1 »

Hello Benj

Unfortunately your solution doesn't work (the "RB3" pin still remains at 1L)
I done several tries : particularly with CCP2 alternative pin checked or not

Best regards

JG1
Posts: 20
Joined: Sat Jul 11, 2009 5:00 pm

Re: PWM alternative PIN on PIC18

Post by JG1 »

Hello Benj

I am sorry to insist but I need help.
I have created a circuit, based on ECIO40 and using "RB3" for PWM, wich is diffused in 32 schools and I was convinced they were no problems.

Thanks a lot in advance

Best regards

JG1

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: PWM alternative PIN on PIC18

Post by Benj »

Hello

Ok I have just given this a go here and it seems that you are right and the PWM is locked to RC1. Do you have a timer interrupt free that you could use for generating a bit banged PWM or do you need it to be hardware PWM driven?

If you do need it to be RB3 then do you have a pickit programmer or similar that you could use to reflash the ECIO firmware?

JG1
Posts: 20
Joined: Sat Jul 11, 2009 5:00 pm

Re: PWM alternative PIN on PIC18

Post by JG1 »

Hello Benj

Thank for your reply.

My problem is that we are using ECIO base board (EB061) + ECIO40 circuits + Eblocks in a group of schools and it is important for us to remain in the standard version of firmware.
As well, for our different applications, we need to use sometimes RC1, sometimes RB3. Apart of that we may use a free timer interrupt (other than TMR0) : so please send me a "bit banged PWM", I don't see how it looks.

Thanks in advance

Best regards

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: PWM alternative PIN on PIC18

Post by Benj »

Hello

Ok you are probably best off staying with the default configuration settings then and bit banging the PWM for the RB3 signal.

There is a good example of bit banged PWM available from our Flowcode examples packs and also from this article.

http://www.matrixmultimedia.com/mmforum ... =26&t=6732

Let me know if you need any further help.

JG1
Posts: 20
Joined: Sat Jul 11, 2009 5:00 pm

Re: PWM alternative PIN on PIC18

Post by JG1 »

Hello Benj or Steve

I come to you again after a few monthes because I really need a solution to the problem of the dysfunction of the alternative pin on CCP2 with ECIO40.
Is it possible for you to modify the file "PIC_PWM.ocx" or "ECIO-40.fcd" or other....
I recall that I speak on behalf of 32 schools and that we use Flowcode with secondary school pupils : it's important for us that the macro PWM and its dialog box work correctly (without using a device as "bit banged PWM").
I add that we bougth several hundreds of "kits ECIO" we have chosen for their simplicity of implementation and I hope you can find a simple solution.

Thanks in advance

Best regards from France

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: PWM alternative PIN on PIC18

Post by Benj »

Hello,

We have found a workaround for this problem for you.

Simply download the attached file and inside you will find a couple of files.

Copy the ECIOprog.exe file into your "Flowcode v4\Tools\ECIOprog" folder

Copy the fcd file into your "Flowcode v4\FCD" folder

Then start Flowcode and choose the "ECIO-40_Alt_PWM2.fcd" as your target.

Download any program to the ECIO, it can be a blank program if you like, this will configure the ECIO for use with the alternate PWM pin.

Then go back to your old program that uses the default ECIO40 FCD and your program will now correctly use the alternative CCP2 pin by default. You will have to remember to configure the PWM component appropriatley so that the port direction register is configured correctly.

If you ever need to switch back to RC1 as CCP2 then you will have to modify the "ECIO-40_Alt_PWM2.fcd" FCD file.

Do this by finding the following line in the [config] section.

5=0x80

and change to

5=0x81

Once you have done this perform another simple program using the modded FCD file and your ECIO will be restored to factory settings.

Let me know if you have any problems.
Attachments
ECIO_Config_Override.zip
(349.76 KiB) Downloaded 331 times

JG1
Posts: 20
Joined: Sat Jul 11, 2009 5:00 pm

Re: PWM alternative PIN on PIC18

Post by JG1 »

Hello Benj

Your quick response provides a satisfactory solution to my problem.
It's a little annoying to still be obliged to change the .fcd file to come back but it's not difficult.

Thank you very well.

Best regards

User avatar
Steve
Matrix Staff
Posts: 3434
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: PWM alternative PIN on PIC18

Post by Steve »

You can create another additional FCD file (perhaps called "ECIO-40_PWM2_RC1.fcd"). This will be an exact copy of the "ECIO-40_Alt_PWM2.fcd" file but with 5=0x81 instead of 5=0x80. This will make the transition easier.

Post Reply