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

PORTC does follow LATC

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
JerryR



Joined: 07 Feb 2008
Posts: 130

View user's profile Send private message

PORTC does follow LATC
PostPosted: Wed Jan 10, 2018 12:55 pm     Reply with quote

Simple issue: Can't set PIN_C1 low. LATC bit 1 follows code, but PortC bit 1 can never be cleared. TRIS register is correctly set to 0 (an output). Watching registers in CCS IDE and watching pin on O'scope.


Output used as general I-O. Connected to a motor driver input pin.

Anyone see something that i don't?

Thanks!

Processor- PIC16F1787
IDE- CCS
Compiler PCWH 5.071

Code:

//=============================================================================

void main()
{
//pwm_off();                        //all PWM channels off
output_bit (PIN_C1, 0);
output_bit (PIN_C1,1); 
   


//Ramp_Drive_Motor (500);
   while(TRUE)
   {

   delay_us(1);
   }
}
//=============================================================================




Code:


.h file:

#include <16F1787.h>

#device ICD=TRUE
#use delay(clock=4000000)
#use pwm(output=PIN_E0, timer=2, frequency=1kHz, duty=0, stream= Drive)      //CCP3 Drive PWM


#define        Green_LED               PIN_D1      //green diag LED
#define        Red_LED                 PIN_D0      //red diagnostic LED           

#define        Steer_IN1               PIN_C2      //steer driver in1
#define        Steer_IN2               PIN_C1      //steer driver in2


//CONSTANTS
//steer motor direction
#define     Brake                0     //directs steering motor to brake
#define     Clock                1     //directs steering motor to turn clockwise
#define     Counter_Clock        2     //directs steering motor to turn counter-clockwise   


PCM programmer



Joined: 06 Sep 2003
Posts: 20264

View user's profile Send private message

PostPosted: Wed Jan 10, 2018 1:35 pm     Reply with quote

Quote:
void main()
{
//pwm_off(); //all PWM channels off
output_bit (PIN_C1, 0); // *** Set Pin C0 low for 1 us
output_bit (PIN_C1,1); // *** Then set it high


//Ramp_Drive_Motor (500);
while(TRUE)
{

delay_us(1);
}

}

Your program will only clear pin C1 for a microsecond.
Then you set it high. You wouldn't see it cleared with that test program.
JerryR



Joined: 07 Feb 2008
Posts: 130

View user's profile Send private message

PostPosted: Wed Jan 10, 2018 2:17 pm     Reply with quote

Hi PCM:

No, I used break points on these two lines and stepped through each. Believe me, PORT pin C1 will not clear. LATC bit 1 does change states, however.

Any other suggestions?

Thanks!
JerryR



Joined: 07 Feb 2008
Posts: 130

View user's profile Send private message

PostPosted: Wed Jan 10, 2018 2:31 pm     Reply with quote

Solved--Kind of.

Wasn't the PIC or code at all. For some reason INPUT2 on a Infineon TLE5205-2G has something pulling its input up to 5 volts HARD! Guess it's Infineon's issue.

Thanks!
JerryR



Joined: 07 Feb 2008
Posts: 130

View user's profile Send private message

Pin_C1 sink current
PostPosted: Wed Jan 10, 2018 3:00 pm     Reply with quote

I'm back, sorry...

Looks like the PIC may not be able to sink any current on PIN_C1. I can pull this pin low successfully using a milliamp meter which read about 5uA.

Is there any reason i shouldn't be able to pull 5uA to ground with a PIC16F1787? No significant current requirements on any port C pins.

Thanks!
Ttelmah



Joined: 11 Mar 2010
Posts: 12974

View user's profile Send private message

PostPosted: Wed Jan 10, 2018 3:13 pm     Reply with quote

Could have been damaged if it has been shorted to 5v....

However general rule, always make sure every peripheral on the pin is disabled. So the PSMC controller, timer 1 oscillator, and CCP2.
JerryR



Joined: 07 Feb 2008
Posts: 130

View user's profile Send private message

PostPosted: Wed Jan 10, 2018 3:23 pm     Reply with quote

Hello Ttelmah:

I have two prototypes, professionally built and they look good and perform the same. No inadvertent wrong connections placed on C1. I think I have all the peripheral disabled on C1. I am using CCP3 and timer2. I don't know how to disable the secondary oscillator or PSMC, they were never enabled. Looks like the PIC should default with peripheral off unless specifically enabled.

I am going to run-down all the peripherals.

Thanks Ttelmah!
JerryR



Joined: 07 Feb 2008
Posts: 130

View user's profile Send private message

PostPosted: Wed Jan 10, 2018 3:27 pm     Reply with quote

This must be it. Microchip data sheet says (13.7.6) PSMC1B and CCP2 have priority over general IO. Now, how do you cut both off?

Thanks
Ttelmah



Joined: 11 Mar 2010
Posts: 12974

View user's profile Send private message

PostPosted: Thu Jan 11, 2018 1:39 am     Reply with quote

The PSMC, is meant to be disabled by default. However if something has resulted in anything being written to the PSMC1OEN register it could be acting.
Code:

    SETUP_CCP2(CCP_OFF); //disables the CCP
    PSMC_PINS(1,FALSE); //de-select PSMC1 from driving any pins
JerryR



Joined: 07 Feb 2008
Posts: 130

View user's profile Send private message

PostPosted: Thu Jan 11, 2018 6:16 am     Reply with quote

Ttelmah:

Thanks! Yes, I just fixed the issue by both the "higher priority" peripherals. I believe CCP2 was responsible for "blocking" PIN_C1. I can't understand why the peripheral was active given my code,and why general IO doesn't rank higher in priority.

You were also good enough to answer a recent "SOS" regarding MPLAB IDE not working with CCS Compiler and Microchip debugger on a single PC. Still haven't figured that one out, but my current set-up on the PC uses CCS IDE and one of their debuggers. I LIKE CCS IDE so I'm happy for the change.

Thanks you so much for all you do to help others in the group through tough problems.

Best regards
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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