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

pull up pb with PIC12F675

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







pull up pb with PIC12F675
PostPosted: Thu Apr 21, 2005 10:20 am     Reply with quote

Hello,

I have a pb with pullups of PIC12F675, on port GPO and GP1. I do this code, but the pull ups are not enable, where is the problem?
...
Code:

#byte WPU = 0x95 ///< Registre des Weak UP Pullup
#byte OPTION_REG = 0x81 ///< Registre OPTION_REG
VOID main( VOID )
{
   // Setup I/O PORTS
   set_tris_a( 0b11011111 ); // 0 output, 1 input
   
   /*WPU = 0x03; // pull up for GP0 et GP1
   OPTION_REG &= 0x7F; // Enable Pull-ups*/   

   port_a_pullups(0x03);
         
   for(;;); // GP0 and GP1 are low (nothing is plug on GP0 and GP1)
   ....
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Apr 21, 2005 12:58 pm     Reply with quote

What is your version of the compiler ?
vincent74
Guest







PostPosted: Fri Apr 22, 2005 12:16 am     Reply with quote

answer:

Code:

#byte CNCOM = 0x19 ///< Registre CNCOM du comparateur //<<<<<
VOID main( VOID )
{
   
  delay_ms(100);
  // Setup I/O PORTS
  set_tris_a( 0b11011111 ); // 0 output, 1 input

  CNCOM = 0x07; // config of comparator pin....//<<<<<<<<<<<<<
   
  port_a_pullups(0x03);
  // pull ups OK
  ....
}


Sorry, I should read the datasheet before start programming.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 22, 2005 1:13 am     Reply with quote

That's why I asked what was your version of the compiler.
In PCM vs. 3.222, the start-up code inserted by the compiler
correctly turns off the comparators. I suspected that your
version did not, but wanted to confirm it.

This is the start-up code produced by vs. 3.222:
Code:

0000                00219 ..... void main()   
0000                00220 ........... {   
0019 0184       00221 CLRF   04
001A 301F       00222 MOVLW  1F
001B 0583       00223 ANDWF  03,F
001C 131F       00224 BCF    1F.6
001D 1683       00225 BSF    03.5
001E 101F       00226 BCF    1F.0
001F 109F       00227 BCF    1F.1
0020 111F       00228 BCF    1F.2
0021 119F       00229 BCF    1F.3
0022 3007       00230 MOVLW  07      // W = 7
0023 1283       00231 BCF    03.5    // Bank 0
0024 0099       00232 MOVWF  19      // Set CMCON = 7
0025 1683       00233 BSF    03.5
0026 0805       00234 MOVF   05,W
0027 1283       00235 BCF    03.5
0028 0819       00236 MOVF   19,W
0029 118C       00237 BCF    0C.3
Guest








PostPosted: Mon Apr 25, 2005 1:01 pm     Reply with quote

I guess that's why I always try to configure things the way I want it even if I don't have to.

A test program I used for the 12F675.
Code:
#include "C:\Program Files\PICC\Programs\12F675\test.h"

#BYTE porta = 0x05

void main()
{

   setup_adc_ports(0);
   setup_adc(ADC_OFF);
   setup_counters(RTCC_INTERNAL,RTCC_DIV_2);
   setup_timer_1(T1_DISABLED);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   set_tris_a(0x0F);

   while(1)
   {
      porta = 0x00;
      delay_ms(1);
      porta = 0x30;
      delay_cycles(2);
   }

}
Bilgehan



Joined: 18 Oct 2012
Posts: 1

View user's profile Send private message

Config Pull up problem
PostPosted: Thu Oct 18, 2012 7:36 am     Reply with quote

Dear all,

I have been working on PIC 12F675 and want to use internal pull ups. GP0, GP1 and GP2.

But I could not get success,

Is it ok only use port_a_pullups(0bxxxxxx); command to make a config?
How can I canfig, the internal pull ups.

It works with assembly code.

Or what?

MY CODES
Code:

.
.
.
void main()
{
   set_tris_a(0b00000111);         
   port_a_pullups(0b00000111);
   setup_adc_ports(NO_ANALOGS);   
   setup_adc(ADC_OFF);         
   setup_comparator(NC_NC_NC_NC);
   
   
   output_a(0x00);               
   output_high(ROLE);            
   output_high(LED);
   
   while(1)
   {
      
            
      if(SAGYAT == 1)
      {
      delay_ms(10);
      ONDAKIKA=0;
      BIRDAKIKA=0;
      output_high(ROLE);
      output_high(LED);
      delay_ms(100);
      }   
      else if(SAGYAT == 0)
      {
      delay_ms(10);
      ONDAKIKA=0;
      BIRDAKIKA=0;
      output_low(ROLE);
      output_low(LED);
      delay_ms(100);
      }      


What I want to do:
I have 3 pins and if one of them or both or all or combination of them active or passive, do smth, such open/close relay.
I want to use internel pull ups but could not.

Any idea!

Thanks.
Ttelmah



Joined: 11 Mar 2010
Posts: 19520

View user's profile Send private message

PostPosted: Thu Oct 18, 2012 8:10 am     Reply with quote

#use fast_io(a)

By default the compiler is set to 'standard_io' mode.
In standard_io mode, the instruction:

output_a(0x00);

sets the _whole_ of portA as outputs.

Two choices. Either switch to fast_io mode, _or_ change the order of the instructions.

Just use:
Code:

output_a(0x00);
set_tris_a(0b00000111);
port_a_pullups(0b00000111);

This way, you pre-load the output latch with '0', and only then set the TRIS, which then doesn't get changed on the low bits, provided you only use the bit I/O instructions (output_high and output_low).

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