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

16F631 port C problems

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



Joined: 10 Feb 2011
Posts: 2

View user's profile Send private message

16F631 port C problems
PostPosted: Thu Feb 10, 2011 7:09 am     Reply with quote

Hi,

I wondered if anyone could help me with a problem I have with PIC 16F631?

I've used the code below to switch on all eight pins of port C, but 0-3 pulse between zero and 5 volts when instructed to be 'on'. The waveform is a square wave, frequency of around 11Khz, on for 10uS, off for around 80uS.

Bits 4-7 work correctly, producing 5v.

Should I disable the comparator and or analog that shares the pins...?
Code:

#include<16F631.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES NOCPD                    //No EE protection
#FUSES NOPROTECT                //Code not protected from reading
#FUSES PUT                      //Power Up Timer
#FUSES NOBROWNOUT               //No brownout reset

#define AVDNEG09 PIN_C0      
#define AVDDBB PIN_C1
#define VDD PIN_C2
#define ADDADC PIN_C3

#define AVDD1V8 PIN_C4      
#define AVDD1V8A PIN_C5
#define AVDNEG1V8 PIN_C6
#define VDE PIN_C7
#use delay(clock=8000000)

setup_comparator_(NO_COMPARATORS);
setup_adc_(NO_ANALOGS);
#use standard_IO(C)


void main (void)
{
  while(1==1)
   {
     output_high(AVDNEG09);
     output_high(AVDDBB);
     output_high(VDD);
     output_high(ADDADC);
     output_high(AVDD1V8);
     output_high(AVDD1V8A);
     output_high(AVDNEG1V8);
     output_high(VDE);
    }

}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 10, 2011 1:58 pm     Reply with quote

These two lines in bold need to be placed at the start of main(). They
don't do anything when placed above main().
Quote:

setup_comparator_(NO_COMPARATORS);
setup_adc_(NO_ANALOGS);

#use standard_IO(C)


void main (void)
{
while(1==1)
{
output_high(AVDNEG09);
output_high(AVDDBB);
output_high(VDD);
output_high(ADDADC);
output_high(AVDD1V8);
output_high(AVDD1V8A);
output_high(AVDNEG1V8);
output_high(VDE);
}

}


Also, always post your compiler version. This allows us (the forum
members, not CCS), to check the .LST file and look for bugs in your
version.
Colin_Brenton



Joined: 10 Feb 2011
Posts: 2

View user's profile Send private message

PostPosted: Thu Feb 17, 2011 2:34 am     Reply with quote

Hi,

For those who like to know the outcome of these things, it transpired there was a bug in the CCS compiler, such that the analouge pins were not being set to digital. Adding an instruction to manually write zeros to the correct register solved the problems.

Thanks PCM programmer for your advice Smile


BR,
Colin
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