View previous topic :: View next topic |
Author |
Message |
kalyan
Joined: 16 May 2014 Posts: 7
|
digital input not working in dspic33ep512mu810 |
Posted: Fri Mar 23, 2018 4:09 am |
|
|
If i configure a pin as digital input it is not working. If i configure the same pin as output it is working correctly. My device is dspic33ep512mu810. ccs compiler version is 5.045.
Code: |
void main()
{
delay_ms(10);
set_pullup(TRUE,PIN_A2);
delay_ms(10);
while(TRUE)
{
delay_ms(10);
if(input(in_1==0))
{
output_high(pin_b7);
delay_ms(100);
output_low(pin_b7);
delay_ms(100);
}
}
} |
Code: |
#include <33EP512MU810.h>
#build (stack=512)
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOCKSNOFSM //Clock Switching is disabled, fail Safe clock monitor is disabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOJTAG //JTAG disabled
#FUSES PUT128 //Power On Reset Timer value 128ms
#device ICSP=1
#use delay(clock=96MHz,crystal=12MHz)
#use FIXED_IO( B_outputs=PIN_B7,PIN_B6 )
#define in_1 PIN_A2 |
|
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Fri Mar 23, 2018 5:28 am |
|
|
while I'e never used that PIC..some general comments
if those pins are 'selectable' (PPS ?) , you need to preslect them. There's a sticky top of the postings..
if those pins can be analog, you need to disable the ADC for those pins
if those pins can be comparator inputs, again the comparator needs to be disabled..
if there are any other internal peripherals, they must be disabled from 'input' pins. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: digital input not working in dspic33ep512mu810 |
Posted: Fri Mar 23, 2018 8:43 am |
|
|
kalyan wrote: | If i configure a pin as digital input it is not working.
#define in_1 PIN_A2
if(input(in_1==0))
{
output_high(pin_b7);
delay_ms(100);
output_low(pin_b7);
delay_ms(100);
}
}
}
|
The input() function requires a CCS pin number constant as the
parameter. You are not doing that. You are using the result of an
expression as the parameter. You need to fix it. |
|
|
|