+ Reply to Thread
Results 1 to 5 of 5

Thread: 12F683 boostc configuration help

  1. #1
    RobertTrue Newbie
    Join Date
    Aug 2009
    Posts
    4

    Default 12F683 boostc configuration help

    Hi I'm new to pic programming but not new to C programming,
    Can someone help me configure a 12F683 in boostC I just want to be able to use the gpio register to blink leds on the 5 output pins. I have read most of the datasheet and the newcomers sticky and I still cant figure it out.

    Here is the code so far.
    Code:
    #include <system.h>
    #include <PIC12F683.h>
    
    #pragma DATA _CONFIG, _WDT_OFF & _INTOSCIO
    #pragma CLOCK_FREQ 4000000
    
    char count = 00000000b;
    char GPP0 = 00000001b;
    char GPP1 = 00000010b;
    char GPP2 = 00000100b;
    char GPP4 = 00010000b;
    char GPP5 = 00100000b;
    
    
    void main()
    {
    
     osccon      = 01100001b; 
    
     cmcon0      = 7;    //set digital IO 
     
     adcon0      = 0 ;
     
     ansel       = 00000000b;
     
     wpu         = 0;
     
     trisio      = 00001000b;    //set input , output
     gpio        = 00000000b;
     
     
     
     
    while(1)
    {
        
     
        set_bit(gpio,GPP0);
        set_bit(gpio,GPP1);
        set_bit(gpio,GPP2);
        set_bit(gpio,GPP4);
        set_bit(gpio,GPP5);
        
        delay_ms(1000);
        
        clear_bit(gpio,GPP0);
        clear_bit(gpio,GPP1);
        clear_bit(gpio,GPP2);
        clear_bit(gpio,GPP4);
        clear_bit(gpio,GPP5);
        
        delay_ms(1000);
       
    }
    
    
    
    }
    
    Last edited by RobertTrue; 11th August 2009 at 05:02 PM.


  2. #2
    RobertTrue Newbie
    Join Date
    Aug 2009
    Posts
    4

    Default

    when I run this program all of the pins blink except 2 and 7 (GP5,GP0)

  3. #3
    RobertTrue Newbie
    Join Date
    Aug 2009
    Posts
    4

    Default

    Any ideas as to what I'm doing wrong?
    Can someone post the configuration that they would use?
    Its doesn't have to be in C

  4. #4
    kpatz Good kpatz Good
    Join Date
    May 2009
    Location
    NH
    Posts
    305

    Default

    Try changing:
    Code:
    char GPP0 = 00000001b;
    char GPP1 = 00000010b;
    char GPP2 = 00000100b;
    char GPP4 = 00010000b;
    char GPP5 = 00100000b;
    
    to

    Code:
    char GPP0 = 0;
    char GPP1 = 1;
    char GPP2 = 2;
    char GPP4 = 4;
    char GPP5 = 5;
    
    The set_bit and clear_bit functions (bsf and bcf in assembly) take the bit number (0-7) as a parameter, not a bit mask.

    You could also set all the GPIO bits for your LEDs with a single command: gpio = 00110111b;
    and clear them with gpio = 0;
    Last edited by kpatz; 11th August 2009 at 08:45 PM.

  5. #5
    RobertTrue Newbie
    Join Date
    Aug 2009
    Posts
    4

    Default

    Quote Originally Posted by kpatz View Post
    Try changing:
    Code:
    char GPP0 = 00000001b;
    char GPP1 = 00000010b;
    char GPP2 = 00000100b;
    char GPP4 = 00010000b;
    char GPP5 = 00100000b;
    
    to

    Code:
    char GPP0 = 0;
    char GPP1 = 1;
    char GPP2 = 2;
    char GPP4 = 4;
    char GPP5 = 5;
    
    The set_bit and clear_bit functions (bsf and bcf in assembly) take the bit number (0-7) as a parameter, not a bit mask.

    You could also set all the GPIO bits for your LEDs with a single command: gpio = 00110111b;
    and clear them with gpio = 0;
    That was the problem it works now TYVM.

+ Reply to Thread

Similar Threads

  1. BoostC LCD functions
    By usif in forum Micro Controllers
    Replies: 4
    Latest: 21st April 2009, 01:32 AM
  2. BoostC Help
    By usif in forum Micro Controllers
    Replies: 16
    Latest: 15th January 2009, 10:17 AM
  3. BoostC 12F683 Serial I/O Example
    By Mike, K8LH in forum Micro Controllers
    Replies: 5
    Latest: 2nd October 2008, 06:21 PM
  4. BoostC USART 18F
    By AtomSoft in forum Micro Controllers
    Replies: 9
    Latest: 29th June 2008, 04:02 PM
  5. math.h and lib for BoostC?
    By futz in forum Micro Controllers
    Replies: 3
    Latest: 31st March 2008, 05:29 AM

Tags for this Thread