Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 16, 2024, 12:03:58 12:03


Login with username, password and session length


Pages: [1]
Print
Author Topic: Stuck with problem in 16f777  (Read 4263 times)
0 Members and 1 Guest are viewing this topic.
bajrang
Active Member
***
Offline Offline

Posts: 145

Thank You
-Given: 245
-Receive: 79


« on: March 24, 2006, 10:23:05 10:23 »

Dear friends,
I am trying to use the 3 CCP modules in 16F777. CCP1 and CCP2 work perfectly but I am unable to initialize CCP3. I am attaching my code (proton compiler 2.2 used).PLEASE help.
Warm regards,
bajrang
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1200

Thank You
-Given: 544
-Receive: 408



« Reply #1 on: March 24, 2006, 06:33:24 18:33 »

16f877 does not have 3 ccp modules only 2 thats why ccp3 don't work use HPWM
 
wizpic
« Last Edit: March 24, 2006, 06:36:25 18:36 by Wizpic » Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
bajrang
Active Member
***
Offline Offline

Posts: 145

Thank You
-Given: 245
-Receive: 79


« Reply #2 on: March 25, 2006, 05:47:37 05:47 »

Dear wizpic,
I am using 16F777 and not 16F877.
16F777 as per the datasheets has 3 CCP modules.
Warm regards,
bajrang
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1200

Thank You
-Given: 544
-Receive: 408



« Reply #3 on: March 25, 2006, 08:27:51 08:27 »

sorry i must have miss read your post that's eh wife for you (don't spend to much time on there)
 
i must go and get my eyes tested
Sorry i dont have 16f777 i will have a look it should work
 
wizpic
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
vsmvdd
Junior Member
**
Offline Offline

Posts: 92

Thank You
-Given: 1
-Receive: 25


« Reply #4 on: March 26, 2006, 02:00:03 02:00 »

code looks fine
 
must be a compiler bug
however give it preset routine first instead of a pattern to test it
 
then report the bug
 
if its an old version of the comiler try a later one
maybe the register isnt getting addressed properly
 
a common complaint
Logged
tasosstr
Junior Member
**
Offline Offline

Posts: 75

Thank You
-Given: 95
-Receive: 14


« Reply #5 on: March 26, 2006, 03:27:13 03:27 »

Hello bajrang,

Proton compiler dosn't have yet support the 3rd CCP module so you have to write in asm.

That i saw in Proton forum and i think has answer Les or Tim i don't remember.

Try a search with HPWM in proton forum...

Best Regards,
Tasosstr
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1200

Thank You
-Given: 544
-Receive: 408



« Reply #6 on: March 26, 2006, 10:00:15 10:00 »

i think you will find that Proton does support 3 CCP modules
 
 
Quote
Les said
At the moment, the HPWM command only supports 2 pwm channels.
 
I am currently looking into more channels, but Microchip have not made it easy as they shift around the configurations for different PICmicro devices, and some have several channels of PWM, each with a slightly different setup.
 
I've said this in the past and I'll say it again. The HPWM command was implemented so that PBP users would not have withdrawal symptoms. The best way to use the PWM channels is to access the PICmicro registers yourself.
 
Personally, I don't go anywhere near the HPWM command because it's inefficient in so much as it has to calculate the period etc everytime it's used. Even if the change is so small a single register change could do the job.

you may want to try this
Setting up hardware PWM really isn't that hard.
 
From the examples in your 16F767 datasheet;
 
Setup 10-bit PWM for 1.22kHz with a 20MHz osc.
 
 
Code:
 Device 16F767
Declare XTAL 20
 
' Word vars for 10-bit value of each PWM duty cycle
Dim Duty1 As Word ' Channel #1
Dim Duty2 As Word ' #2
Dim Duty3 As Word ' #3
 
' Set CCPx pins to outputs
TRISC.2=0 ' CCP1 output
TRISC.1=0 ' CCP2 output (could also be assigned to RB3)
TRISB.5=0 ' CCP3 output
 
' Set CCP modules to PWM mode
CCP1CON = %00001100 ' Mode select = PWM
CCP2CON = %00001100 ' Mode select = PWM
CCP3CON = %00001100 ' Mode select = PWM
 
' Set period up for 1.22kHz PWM freq
PR2 = $FF
 
' Set TMR2 up for 1:16 prescale & turn it on
T2CON = %00000110 ' TMR2 ON 1:16 prescale
 
Duty1 = 512 ' 50% duty cycle. 1024/2 "10-bit resolution"
CCP1CON.4 = Duty1.0 ' Setup 10-bit duty cycle as
CCP1CON.5 = Duty1.1 ' a 10-bit word
CCPR1L = Duty1 >> 2
 
Duty2 = 512
CCP2CON.4 = Duty2.0
CCP2CON.5 = Duty2.1
CCPR2L = Duty2 >> 2
 
Duty3 = 512
CCP3CON.4 = Duty3.0
CCP3CON.5 = Duty3.1
CCPR3L = Duty3 >> 2

 
just alter the pic type and try it, it should work
 
wizpic
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
bajrang
Active Member
***
Offline Offline

Posts: 145

Thank You
-Given: 245
-Receive: 79


« Reply #7 on: March 28, 2006, 04:01:11 04:01 »

Dear wizpic,
the code that you wrote works like a charm! thank you very much.
warm regards and thanks to all ,
bajrang
Logged
Wizpic
Global Moderator
Hero Member
*****
Offline Offline

Posts: 1200

Thank You
-Given: 544
-Receive: 408



« Reply #8 on: March 28, 2006, 03:39:22 15:39 »

Your welcome I just like to point out i did not right that code i just copiedit of the Proon forum, I did not have time or the PIC to test it on, but were al here to help each other
 
My code might not have been that neat but it would to the same job
 
but thanks any way
 
wizpic
Logged

When you think, "I can't do anymore. I need a break," that is the time to challenge yourself to keep going another five minutes. Those who persevere for even an extra five minutes will win in life..
alejandro
Guest
« Reply #9 on: May 04, 2006, 09:59:44 21:59 »

Anybody has worked with a monophasic inverter with regulation of the output voltage?
Logged
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright © 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC