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 pullups

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







Problem with pullups
PostPosted: Thu Jan 10, 2008 6:43 am     Reply with quote

Hi

When I compile this code

Code:

#include <12F508.h>
#fuses INTRC,NOWDT,PROTECT,NOPROTECT,MCLR
#use delay(clock=4000000)

#define ON 1
#define OFF 0

#define FIRE   pin_b0      //ouput
#define ONOFF   pin_b3      //input
#define ADJUST   pin_b1      //input
#define LED      pin_b2      //output


void main(void)
{
/******************************************************************************
                        Initilisation
******************************************************************************/

   unsigned char rate = 30;   //Steps of 5x2ms. Set initial rate to 300ms (approx 3 Hz)
   unsigned char temp = 0;
   boolean enable = OFF;      //Set fire to off

    set_tris_b(0x3C);         //Set PORT to desired I/O
   port_b_pullups(TRUE);      //Turn on PULLUPS
   output_low(LED);         //Turn off LED
   output_low(FIRE);         //Turn off output

/******************************************************************************
                            Main
******************************************************************************/

   while(1)
   {
      if (input(ONOFF))         //if enable is pressed
      {   
         enable^=0x01;         //Toggle enable
      }

      if (enable)
      {
         do
         {
            delay_ms(5);      //Approx 10ms pulse width, 50% duty cycle
            output_high(FIRE);
            delay_ms(5);
            output_low(FIRE);
         }while (temp++ < rate);   //Repeat to produce pulse of desired width
         temp = 0;            //Reset temp
      }
   }
}


I get the foloowing error

Clean: Deleting intermediary and output files.
Clean: Done.
Executing: "C:\Program Files\Microchip\Third Party\PICC\CCSC.EXE" "main.c" +FB +DF +LN +T -A +M +Z +Y=9 +EA
*** Error 12 "C:\Program Files\Microchip\Projects\Rapid Fire\main.c" Line 50(1,15): Undefined identifier -- port_b_pullups
1 Errors, 0 Warnings.
Halting build on first failure as requested.
BUILD FAILED: Thu Jan 10 12:36:20 2008

Am I missing a header file or something?

TIA
Guest








PostPosted: Thu Jan 10, 2008 6:59 am     Reply with quote

Think I may have found the answer

From manual

Availability:
Only 14 and 16 bit devices (PCM and PCH). (Note: use SETUP_COUNTERS on PCB parts).

How do I do this for the 12F508 if this is the case?
ckielstra



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

View user's profile Send private message

PostPosted: Thu Jan 10, 2008 9:08 am     Reply with quote

Anonymous wrote:
Think I may have found the answer

From manual

Availability:
Only 14 and 16 bit devices (PCM and PCH). (Note: use SETUP_COUNTERS on PCB parts).

How do I do this for the 12F508 if this is the case?
Read your post again, you have written down the answer yourself.

The 12 bit devices are stripped down to the bare minimum. Because of register changes the port_b_pullups() function is not working. Use setup_counters instead. See the header file of your chip for details and what options are available.

Here is an example that I think might work (not tested):
Code:
SETUP_COUNTERS(RTCC_INTERNAL | RTCC_DIV_32 | RTCC_8_BIT, WDT_1152MS | DISABLE_PULLUPS);


Note that the datasheet is not very clear, but it seems like weak pull ups are only supported on pins GP0, GP1 and GP3.
Ttelmah
Guest







PostPosted: Thu Jan 10, 2008 9:41 am     Reply with quote

'DISABLE_PULLUPS', turns the pullups off.
Any setup line for the timers, _without_ this, defaults to enabling them.
Page 17 of the data sheet,makes the supported pins pretty clear (only GP0, 1 & 3, as you say).

Best Wishes
Guest








PostPosted: Thu Jan 10, 2008 9:45 am     Reply with quote

Thats great!! Thanks for that, got it working now! How did you figure that one out??
Guest








PostPosted: Thu Jan 10, 2008 10:19 am     Reply with quote

If I enable the internal pullups and set the relevant IO to input, will I see the GPIO register in the Special Functions Register window (MPLAB) go to 1 to reflect the pull up?
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