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

Cannot output low

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







Cannot output low
PostPosted: Thu Jul 03, 2008 3:41 pm     Reply with quote

hello, i am trying to learn how to develop on the pic 18f4550 and am running into, a probably trivial problem.

here is my code

Code:
#include "18F4550.h"

int main(void)
{
   output_low(PIN_A1);
   return 0;
}


All i want it to do is output a low on pin A1, but when i check the voltage with a multimeter, it is 4.867 volts. what am i doing wrong?
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Jul 03, 2008 3:50 pm     Reply with quote

Just a few hours ago somebody asked almost the same question. The other question was for an input but most likely the same cause: http://www.ccsinfo.com/forum/viewtopic.php?t=35297
John5788
Guest







PostPosted: Thu Jul 03, 2008 3:59 pm     Reply with quote

i changed the code a bit to this:

#include "18F4550.h"

Code:
int main(void)
{
   setup_adc(ADC_OFF);
   setup_adc_ports( NO_ANALOGS );
   while(1)
   {
      output_low(PIN_A1);
   }
   return 0;
}


and it is still outputting 5v.

more information: i am using the picdem fsusb demo board right now.
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Jul 03, 2008 4:13 pm     Reply with quote

My mistake, the outputs on this chip are not affected by the analog port settings (only the inputs are affected).

Your program is so simple that it can only fail when something very basic is wrong. Did you post all program code? Now the processor include and fuses are missing.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jul 03, 2008 4:17 pm     Reply with quote

Quote:
I am using the picdem fsusb demo board right now.

This board comes with a built-in USB bootloader that uses pin A1
to detect if a USB cable is plugged into the board. See page 11
(page 15 in the Acrobat reader) and also the schematic:
http://ww1.microchip.com/downloads/en/DeviceDoc/51526b.pdf
John5788
Guest







PostPosted: Thu Jul 03, 2008 5:13 pm     Reply with quote

ok so i took a glance at the datasheet some more and it says RD0 is connected to the D1 LED, so i modified my code:

Code:
#include "18F4550.h"

int main(void)
{
   while(1)
   {
      output_high(PIN_D0);
   }
   return 0;
}


now the LED lights up, its working!

so as I understand, I cannot use RA0, RA1, RB0, RB1, RB2 for anything interesting, but all other lines are fair for use?
Ttelmah
Guest







PostPosted: Fri Jul 04, 2008 2:24 am     Reply with quote

You can use A0, A1, B0, B1, B2 as normal, _but_ you need to turn off the devices attached to them.
Quite a few things involved:
1) Fuses - NOPBADEN - otherwise PORTB, wakes up set to use for the ADC
2) setup_adc(NO_ANALOGS) (you already have this one).
3) setup_comparator(NC_NC_NC_NC) - otherwise the comparator uses various pins.

Best Wishes
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