CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

18F87K22 CCP2 problem. Resolved!!!
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
curt2go



Joined: 21 Nov 2003
Posts: 200

View user's profile Send private message

18F87K22 CCP2 problem. Resolved!!!
PostPosted: Sun Mar 04, 2012 4:40 pm     Reply with quote

I have fought with this issue forever!!! I am having trouble with outputing anything on this pin. I have tried setting it low, setting it high using the PWM output. Nothing. I have checked hardware and no issues. Its the same on 2 boards.

Even setting tris C to 0x00 and trying output low does nothing.

Am I missing something with this chip?

When trying PWM I set the fuse to CCP1C1. Let me know if anyone else has had issues here.

I also looked in search and used some the code other put up of their working products with 67k22.
Help please. 4.128 compiler version.


Last edited by curt2go on Sun Mar 04, 2012 8:13 pm; edited 1 time in total
PCM programmer



Joined: 06 Sep 2003
Posts: 21477

View user's profile Send private message

PostPosted: Sun Mar 04, 2012 4:51 pm     Reply with quote

Did you try the work-around shown in this post ? It may apply to your
problem:
http://www.ccsinfo.com/forum/viewtopic.php?t=44564&start=8
curt2go



Joined: 21 Nov 2003
Posts: 200

View user's profile Send private message

PostPosted: Sun Mar 04, 2012 5:10 pm     Reply with quote

Just tried it.. No luck.. . it does seem like my Rc0 pin is not functioning either. They(Rc1,Rc0) almost have the same voltage on them. 3.872 and 3.868.. I am even pulling them both low. No short between them on the board or to ground or VCC....

On the other code the 87K22 does not have the PWM2CON register... So I just deleted the line unless the 87K22 calls it something else?
PCM programmer



Joined: 06 Sep 2003
Posts: 21477

View user's profile Send private message

PostPosted: Sun Mar 04, 2012 5:23 pm     Reply with quote

Post a complete, but very short test program that shows the problem.
It has to be compilable when I copy it into MPLAB. It must have the
#include for the PIC, #fuses, #use delay(), main(), etc. Tell me what PIC
pin you are looking at with the oscilloscope to verify that it works or fails.
If you have any external circuits connected to that pin, post a schematic
or describe them.
curt2go



Joined: 21 Nov 2003
Posts: 200

View user's profile Send private message

PostPosted: Sun Mar 04, 2012 5:31 pm     Reply with quote

It just goes to a Transistor through a 1k resistor. Thanx for the help. Its very perplexing. I have all the other PWM working fine.
Code:

#include <18F87K22.h>
#fuses NOWDT,PROTECT,BROWNOUT,PUT,NODEBUG,NOCPD,CPB,NOMCLR

#fuses CCP2C1  //selects Pin C1 for CCP2
//#fuses CCP2B3  //selects Pin B3 for CCP2

#device *=16
#device HIGH_INTS=TRUE
#device ADC=12


#use delay(clock=8000000)   //8 MHz osc

#byte CCP2CON  = 0xF4E
//#byte PWM2CON  = 0xF65
#byte ECCP2AS  = 0xF52
#byte PSTR2CON = 0xF1B

void my_setup_ccp2(int32 mode) 
{
output_low(PIN_C1);   // This assumes "standard i/o" mode is used
CCP2CON = make8(mode, 0);             
//PWM2CON = 0;             
ECCP2AS = make8(mode, 2);     
if(make8(mode, 3) == 0x00)  // If no steering pin was specified, use P1A
   PSTR2CON = 1;         
}


void main()
{   
long int i;
setup_oscillator(OSC_8MHZ );
set_tris_c(0b00000000);

  setup_timer_0(RTCC_INTERNAL|RTCC_DIV_8|RTCC_8_bit);    //1.0 ms overflow
  setup_timer_1(T1_INTERNAL|T3_DIV_BY_4);
  setup_timer_2(T2_DIV_BY_16,255,1);  //512 us overflow, 512 us interrupt
  setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
  setup_timer_4(T4_DIV_BY_16,100,5);

  my_setup_ccp2(CCP_PWM);

while(TRUE){

for(i=0;i<1024;i++){
   delay_ms(100);
   set_pwm2_duty(i);
}

}

  }
curt2go



Joined: 21 Nov 2003
Posts: 200

View user's profile Send private message

PostPosted: Sun Mar 04, 2012 5:44 pm     Reply with quote

Looking at pin 35.. RC1... Sorry forgot that one.
curt2go



Joined: 21 Nov 2003
Posts: 200

View user's profile Send private message

PostPosted: Sun Mar 04, 2012 5:51 pm     Reply with quote

I am not able to output a low or a high signal on that pin as well.. ??
I have checked my hardware 25 times.. ........
PCM programmer



Joined: 06 Sep 2003
Posts: 21477

View user's profile Send private message

PostPosted: Sun Mar 04, 2012 6:13 pm     Reply with quote

Can you try a simple program like this:
Code:

#include <18F87K22.h>
#fuses INTRC_IO,NOWDT,PUT,BROWNOUT,CCP2C1
#use delay(clock=8M)

//======================================
void main(void)
{
setup_ccp2(CCP_PWM); 
setup_timer_2(T2_DIV_BY_1, 255, 1);
set_pwm2_duty(120);

while(1);
curt2go



Joined: 21 Nov 2003
Posts: 200

View user's profile Send private message

PostPosted: Sun Mar 04, 2012 6:28 pm     Reply with quote

Didn't work..

The problem with the RC0 as well is making me thing i am missing something on my hardware but it is a very simple circuit the same as all the other PWMs that I have been using for years.. Arrrgggg.. Smile

Does that code work for you?
PCM programmer



Joined: 06 Sep 2003
Posts: 21477

View user's profile Send private message

PostPosted: Sun Mar 04, 2012 6:41 pm     Reply with quote

I'm not at the company right now so I can't test it in hardware. I am
also out of the office tomorrow (Monday). So, I really can't test it
in hardware until Tuesday morning. I am sure that when I do, I will be
able to make it work unless it's some compiler problem with the #fuses.
dyeatman



Joined: 06 Sep 2003
Posts: 1837
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Mar 04, 2012 6:49 pm     Reply with quote

I don't have the 18F87K22 but I do have the 18F46K22 and it works for me.
The output on mine is RC1 (pin 16).
_________________
Google and Forum Search are some of your best tools!!!!
curt2go



Joined: 21 Nov 2003
Posts: 200

View user's profile Send private message

PostPosted: Sun Mar 04, 2012 6:51 pm     Reply with quote

I am going to build a new board with nothing but the processor and the decoupling caps on it.. I will test it on that.. Something is fishy.... I will update things if i find something out.. Thanx for all the help guys.. TTY
dyeatman



Joined: 06 Sep 2003
Posts: 1837
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Mar 04, 2012 6:58 pm     Reply with quote

Our example doesn't require a crystal at all. It runs on the internal oscillator.
Try to get that running and blink an LED to prove it functions then try one
change at a time. Leave the LED blink in as a "test heartbeat". I include
a heartbeat LED in every prototype and final design.
_________________
Google and Forum Search are some of your best tools!!!!
curt2go



Joined: 21 Nov 2003
Posts: 200

View user's profile Send private message

PostPosted: Sun Mar 04, 2012 7:44 pm     Reply with quote

Board with only processor on it still not working. Still can't get RC0 or RC1 to work. Not even to send out a high. Giving up for the day... PCM I will look on tuesday to see if you tested it or not. Thanx for the help... TTY
curt2go



Joined: 21 Nov 2003
Posts: 200

View user's profile Send private message

Resolved!!!!!!!
PostPosted: Sun Mar 04, 2012 8:12 pm     Reply with quote

Well after alot more reading about the SOSC it shows in that you MUST!!! tell the fuse that you would like the RC0 and RC1 to be digital IO.. This can not be done by setting TRIS... so you must use the

#FUSE SOSC_DIG

Would have liked my 10 hours back!!! Smile BUt its resolved now...
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group