12F683 boostc configuration help

Status
Not open for further replies.

RobertTrue

New Member
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:
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
 
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:

That was the problem it works now TYVM.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…