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 CCS Technical Support

digital input not working in dspic33ep512mu810

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



Joined: 16 May 2014
Posts: 7

View user's profile Send private message Send e-mail

digital input not working in dspic33ep512mu810
PostPosted: Fri Mar 23, 2018 4:09 am     Reply with quote

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: 9229
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Mar 23, 2018 5:28 am     Reply with quote

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

View user's profile Send private message

Re: digital input not working in dspic33ep512mu810
PostPosted: Fri Mar 23, 2018 8:43 am     Reply with quote

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.
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