CCP VS Regular I/O pin?

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
Drakkor
Posts: 41
Joined: Sun Dec 30, 2012 9:34 pm
Has thanked: 5 times
Been thanked: 4 times
Contact:

CCP VS Regular I/O pin?

Post by Drakkor »

Hi. Well here's the deal. I have been using a pic12f675. I am able to decode PWM and light several leds depending on the PWM as to which ones light up (For radio controlled airplane lights). I also have a project that ramps a beacon (LED) up
and down to simulate a red beacon. It also flashes to bright white LEDS to simulate strobe lights. With the pic12f675, it seems impossible to do both on one chip? The project with the flashing LEDS uses a timer interrupt, while the PWM decoder uses polling (constant ). So, I have ordered some pic12f1840 chips which has a ccp module. I can find no good information on how to use it or WHY it is supposed to be better than a regular I/O pin. I have missed an entire week of excersise because I am consumed with learning this and I really need help. Also, I want to stay with an 8 pin chip for small size, at least for now. Keep it simple for me because I am starting to believe that I am retarded!

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: CCP VS Regular I/O pin?

Post by dazz »

Hi Drakkor
These links and pdf's might help, as they describe how it works(bit of heavy reading sorry )

http://www.mikroe.com/chapters/view/6/
http://nptel.iitm.ac.in/courses/Webcour ... me3_16.htm (need to have a search through the text)
http://www.electrosome.com/pwm-pic-microcontroller/ (a bit of text and a c file it may help)


Regards
Dazz
ccpwm.pdf
(109.13 KiB) Downloaded 395 times
Emb PIC Charles Kim Chap13.pdf
(67.76 KiB) Downloaded 407 times
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

Drakkor
Posts: 41
Joined: Sun Dec 30, 2012 9:34 pm
Has thanked: 5 times
Been thanked: 4 times
Contact:

Re: CCP VS Regular I/O pin?

Post by Drakkor »

hi, this is no help as I have been there already . I really need a simple example if you could? Sometime it amazes me that information is so hard to find. I thought I was done using assembly but I wonder if that may be better than Flowcode sometimes?

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: CCP VS Regular I/O pin?

Post by medelec35 »

Hi Drakkor,
It's so much easier and quicker creating an embedded application using Flowcode instead of assembly, C & JAL etc

If you want I can take you though step by step on how to generate PWM.
But first can you give some more details.
E.g PWM frequency, osc speed of your target device, using internal and external osc etc.

Using built in PWM is much better than toggling a pin, especially if other factors like delays wait for inputs etc as these will alter the pwm frequency.
Whereas the inbuilt PWM duty or frequency will not be affected.
Martin

Drakkor
Posts: 41
Joined: Sun Dec 30, 2012 9:34 pm
Has thanked: 5 times
Been thanked: 4 times
Contact:

Re: CCP VS Regular I/O pin?

Post by Drakkor »

Hi, I want to decode the pwm, not make it. I have done it by polling on an I/O pin but I want to see how it would be done on a chip with the built in ccp? I just can't find even the simplest of examples anywhere? Any help would be appreciated : )

Kenrix2
Flowcode v5 User
Posts: 211
Joined: Tue Feb 19, 2013 9:51 pm
Has thanked: 72 times
Been thanked: 177 times
Contact:

Re: CCP VS Regular I/O pin?

Post by Kenrix2 »

Instructions for that are in Microchip's Compiled Tips ‘N Tricks Guide page 3-4. You can also use Flowcode's INT interrupt and achieve similar results. If you use Flowcode's interrupt you still will have to use some C code to enable a timer, to read the timer values and to reset the timer.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: CCP VS Regular I/O pin?

Post by medelec35 »

Drakkor wrote:I want to decode the pwm, not make it.
Yes I understand that, But you wanted to:
Drakkor wrote:I also have a project that ramps a beacon (LED) up
and down to simulate a red beacon.
That's where the built in PWM will be very handy.
Thought you wanted to do this on one chip?
I was thinking of about 2KHz frequency, but was wondering what you had in mind?

Do you know the what the pulse width is that you want to measure?

I'm assuming the pulses have already been stripped from the RF carrier?
Martin

Drakkor
Posts: 41
Joined: Sun Dec 30, 2012 9:34 pm
Has thanked: 5 times
Been thanked: 4 times
Contact:

Re: CCP VS Regular I/O pin?

Post by Drakkor »

Hi, Yes I do want to do both on one chip. I already have a working project with the leds using TMR0 but I want to be able to turn the beacon and strobes off with one switch on my Radio controlled a plane transmitter. I will be measuring between 1 and 2 ms
pulses. I want to turn it on say.....anywhere above 1.5ms pulse. I am able to figure the timing out myself as I have before but what I think (From the previous reply) Is that when I go to do this on the ccp pin, I will need to add some C-code? So far I have been using the Pic12f675. I ordered some Pic12(l)f1840 (I believe the number is right?) but they have the built in enhanced ccp. I know that I have to learn more C but when you can't simulate it, it makes it a lot of work for a newbie (Unpluging the chip, put in breadboard, etc.... : )
I wonder...does Flowcode 6 simulate C-code? It would sure make it easier for me to test out when I add the C-code? Also, still unsure of the order to assign a variable to a timer FCV_xxxxxx = xxxxxx After the FCV_ does the TIMRx go here or the variable name? Thanks in advance : )

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: CCP VS Regular I/O pin?

Post by medelec35 »

Hi Drakko,
Drakkor wrote:I wonder...does Flowcode 6 simulate C-code?
No unfortunately V6 does not simulate C-code
Drakkor wrote:still unsure of the order to assign a variable to a timer
Take a look at this:
http://www.matrixmultimedia.com/mmforum ... 996#p51996
Drakkor wrote: I already have a working project with the leds using TMR0 but I want to be able to turn the beacon and strobes off with one switch on my Radio controlled a plane transmitter. I will be measuring between 1 and 2 ms
pulses. I want to turn it on say.....anywhere above 1.5ms pulse.
I will see if I can make it easier for you by creating a flowchart that should help you.
Won't be able to start on it until later this evening.


Martin
Martin

Drakkor
Posts: 41
Joined: Sun Dec 30, 2012 9:34 pm
Has thanked: 5 times
Been thanked: 4 times
Contact:

Re: CCP VS Regular I/O pin?

Post by Drakkor »

Martin, Thank you so much. Once I see how it's done, I won't forget it : )

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: CCP VS Regular I/O pin?

Post by medelec35 »

Just working on one thing at a time.
I have created a pulse detector.
If pulse measured at RA5 is less than or = 1.2ms then pin RA0 will be 0V
If pulse measured at RA5 is greater then or = 1.3ms then pin RA0 will be 5V

Flowchart was created the way it was to minimize the C code, so it may not be the best way, but it should be the easiest way to understand how it works.
This is just for testing as I have not tested on actual hardware.
Once pulse detector is proven as working, I will then implement the the LED beacon itself.

Martin
Attachments
PWM Detector V1.fcf
(16.25 KiB) Downloaded 268 times
Martin

Drakkor
Posts: 41
Joined: Sun Dec 30, 2012 9:34 pm
Has thanked: 5 times
Been thanked: 4 times
Contact:

Re: CCP VS Regular I/O pin?

Post by Drakkor »

Cool. Thank you. I appreciate all the great help : )

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: CCP VS Regular I/O pin?

Post by medelec35 »

No problem,
Lets hope it works for you.
Martin

Post Reply