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

18F2580 Digitals

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



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

18F2580 Digitals
PostPosted: Tue Nov 09, 2010 4:01 pm     Reply with quote

I have an 18F2580 that has been working properly for a couple of years but now I'm having a hard time getting PortA.0 to act properly for a digital input. It's always high when I read it.

PortA.1 seems to work fine.

I do have setup_adc_ports(No_Analogs) set in my code.

Any ideas what I'm missing out on?
Thanks,
Richard
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 4:17 pm     Reply with quote

1. Post a (complete) little test program that shows the problem.
It should have the #include for the PIC, #fuses, #use delay(), any other
#use statements that are needed, all variable declarations, and a main().
It should compile with no errors.

2. What is your compiler version ?

3. Describe your test circuit, or post a link to a schematic of it.

4. Describe the signal on pin A0. Is it a constant DC level ? What is the
voltage level ?
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 4:49 pm     Reply with quote

Port A.0 goes to ground with a 10k resistor. A dip switch pulls it up to 5 volts. Same for A.1

Code:

#include <18F2580.h>


#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High Speed Clock
#FUSES NOPROTECT                //Code not protected from reading
#FUSES BROWNOUT                 //Reset when brownout detected
#FUSES BORV43                   //Brownout reset at 2.1V
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOCPD                    //No EE protection
#FUSES STVREN                   //Stack full/underflow will cause reset
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOLVP
#FUSES NOWRT                    //Program memory not write protected
#FUSES NOWRTD                   //Data EEPROM not write protected
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES FCMEN                    //Fail-safe clock monitor enabled
#FUSES BBSIZ2K                  //2K words Boot Block size
#FUSES NOWRTC                   //configuration not registers write protected
#FUSES NOWRTB                   //Boot block not write protected
#FUSES NOEBTR                   //Memory not protected from table reads
#FUSES NOEBTRB                  //Boot block not protected from table reads
#FUSES NOCPB                    //No Boot Block code protection
#FUSES LPT1OSC                  //Timer1 configured for low-power operation
#FUSES MCLR                     //Master Clear pin enabled
#FUSES NOXINST                  //Extended set extension and Indexed Addressing mode disabled
     
void main()
{
   Port_B_PullUps(False);
   Setup_adc_ports( NO_ANALOGS );
   Setup_ADC(ADC_OFF);
   setup_spi(SPI_SS_DISABLED);
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_vref(FALSE);


   //Test LED on C4
  output_high(Pin_C4);
 Delay_ms(1000);
 output_low(Pin_C4);

 While (True)
{
  //Turn LED On when A.0 is ON
  if (input(Pin_A0)==1)
    output_high(Pin_C4)
  else
    output_low(Pin_C4);


}


If I use Pin_A1 then it works fine.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 4:51 pm     Reply with quote

What is your compiler version ?

Where is the #use delay() statement ?
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 4:58 pm     Reply with quote

PCH 4.114
#use delay(clock=20000000)

I typed it instead of copy paste.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 5:37 pm     Reply with quote

It works for me. I compiled your program with vs. 4.114 and ran it on
a 18F2580 on a PicDem2-Plus board (non-Rohs version). This board
has a 5K trimpot on pin A0. I used it supply the test voltage for pin A0.
I don't have an LED on pin C4, so I jumpered it over to pin B0 where there
is an LED.

I slowly turned the trimpot so pin A0 would go from 0v to 5v. I put a
voltmeter on pin A0 to see the voltage. When I got to 1.23v, the LED
turned on and stayed on all the way up to 5v. Going back down, it
went off at about 1.23 volts again, and stayed off as I took the voltage
down to 0v. It's working.
rwskinner



Joined: 08 Dec 2006
Posts: 125
Location: Texas

View user's profile Send private message

PostPosted: Tue Nov 09, 2010 5:44 pm     Reply with quote

Looks to be a hardware issue. My older models work fine, my new models off the production line seem to have an issue on the pull down resistor, such as open....

Thanks for your help PCM. I never would have thought every new module I pulled off the shelf would have this issue.

Richard
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