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

Problem with I/O

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



Joined: 15 Mar 2004
Posts: 33
Location: Swiss

View user's profile Send private message Visit poster's website ICQ Number

Problem with I/O
PostPosted: Tue Oct 04, 2005 8:49 am     Reply with quote

I use code below to just turn 3 pins on and off. With this code works only PIN2. Pin0, and PIN1 dont change their states from low to high and visaversa. Whats wrong....

Code:

#include <10F206.h>

#fuses NOMCLR,NOPROTECT,NOWDT
#ROM 0x2007 = {0x0FFB}//----------------------------------------------------------------------Configuration bit

#use delay(clock=4000000)//-------------------------oscilator 4MHZ
//PORT_B_PULLUPS(TRUE);

#use fast_io(B)
#byte GPIO=0x06

#bit CMPOUT=0x07.7//-------------------------------comp output
#bit COUTEN=0x07.6//-------------------------------comp output disable
#bit CMPON=0x07.3//--------------------------------comp enable
#bit CNREF=0x07.2//--------------------------------comp negative voltage ref
#bit CPREF=0x07.1//--------------------------------comp positive voltage ref
#bit CWU=0x07.0//----------------------------------comp weak up on change
#bit GP0=0x06.0//----------------------------------PIN 0
#bit GP1=0x06.1//----------------------------------PIN 1
#bit GP2=0x06.2//----------------------------------PIN 2
#bit GP3=0x06.3//----------------------------------PIN 3


void main() {
#ASM 
// pin3=input, pin0,1,2=output
MOVLW  0x08
TRIS GPIO
// Disable wake-up on pin change, enable weak pull-ups,
// Timer0 source internal, L to H
// Prescaler to WDT, max division 2304mS
   movlw 0x8F
   OPTION
#ENDASM
    while (true) {//-----------------------------------loop forever
      output_low(PIN_B2);//--------------------------mess switch on
      output_low(PIN_B1);//--------------------------mess switch on
      output_low(PIN_B0);//--------------------------mess switch on
      delay_ms(3000);//---30 sec delay
      output_high(PIN_B2);//--------------------------mess switch on
      output_high(PIN_B1);//--------------------------mess switch on
      output_high(PIN_B0);//--------------------------mess switch on
      delay_ms(3000);//---30 sec delay
    } // end of while (TRUE)

} //end of main
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Oct 04, 2005 9:48 am     Reply with quote

Read the data sheet for the 10F206. Look at the pin diagram
for the chip. What functions are available on the GP0 and GP1
pins besides i/o ? What module are those functions in ?
What register controls that module ? Is there a bit in that
register to enable or disable the module ? What is the power-up
default state of that bit ? If it's enabled, then put in a line
of code at the start of your program to write to that bit and
disable the module.
Felix Althaus



Joined: 09 Sep 2003
Posts: 67
Location: Winterthur, Switzerland

View user's profile Send private message

PostPosted: Tue Oct 04, 2005 9:49 am     Reply with quote

Hello

GP0 and GP1 are the comparator inputs. I think you have to first switch off the comparator module to use this pins as I/O.

Happens to me with a PIC12F675...


@ PCM Programmer: I'm sorry I screwed up your pedagogical lesson :-)

mfg
Felix
ckielstra



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

View user's profile Send private message

PostPosted: Tue Oct 04, 2005 9:55 am     Reply with quote

I hate it when other people anwer the question I was just looking into. Mad

Just so I feel I didn't completely waste my time I will give my answer too.

Look at table 5.1 in the datasheet and you will see the comparator sharing the same I/O pins has a higher priority in order of pin function assignment. By default the comparator is enabled. Disable the comparator by adding the command setup_comparators(NC_NC) in the top of your main function.
Vovachess



Joined: 15 Mar 2004
Posts: 33
Location: Swiss

View user's profile Send private message Visit poster's website ICQ Number

PostPosted: Tue Oct 04, 2005 10:21 am     Reply with quote

Thanks ckielstra Wink
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