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

Problems reading a digital input for portb.5

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



Joined: 14 Sep 2015
Posts: 7

View user's profile Send private message

Problems reading a digital input for portb.5
PostPosted: Tue Sep 22, 2015 12:36 pm     Reply with quote

Hello, new to CCS and PIC, I have a PIC18F45J50 and I'm trying to read a digital input, how the circuit is construct if there's a signal (which is a 12v) goes trough a LDO and gets to 3.3 to the micro which is what I'm trying to read.

Here's what I have
Code:

if(INPUT(PIN_B5) == 1)  // CCS says statement always false
{
    output_high(LED0);  // LED
}

output_high(LED1);  // LED

very simple all I'm trying to do is read the input,

help thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Sep 22, 2015 3:15 pm     Reply with quote

I made your code snippet into a test program and compiled it with CCS
compiler vs. 5.049. I don't get any errors or warnings. It compiles OK.
Code:
#include <18F45J50.h>
#fuses HS, NOWDT
#use delay(clock=20M)
#use rs232(baud=9600, UART1, ERRORS)

#define LED0  PIN_B0
#define LED1  PIN_B1

//===========================
void main()
{

if(input(PIN_B5) == 1)   
  {
   output_high(LED0);   
  }

output_high(LED1);   
 


while(TRUE);
}
sonny



Joined: 14 Sep 2015
Posts: 7

View user's profile Send private message

PostPosted: Wed Sep 23, 2015 7:50 am     Reply with quote

is working now, I had the pullups on
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