View previous topic :: View next topic |
Author |
Message |
sonny
Joined: 14 Sep 2015 Posts: 7
|
Problems reading a digital input for portb.5 |
Posted: Tue Sep 22, 2015 12:36 pm |
|
|
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
|
|
Posted: Tue Sep 22, 2015 3:15 pm |
|
|
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
|
|
Posted: Wed Sep 23, 2015 7:50 am |
|
|
is working now, I had the pullups on |
|
|
|