PIC12F629 help

(instructions, reset, WDT, specifications...) PIC12F6xx, PIC16Fxxx, PIC16F6x, PIC16F7x

Re: PIC12F629 help

Postby ric » Mon Nov 30, 2015 2:42 am

scuba_ wrote:That's what it's doing .. but i want it to stop after ten times. Then go to sleep, only to be woken up by GPIO4 going LOW then HIGH again.
...

You didn't have any code actually doing what you describe.
Try this:

Code: Select all
#include"xc.h"

#pragma config MCLRE=OFF , CP=OFF, CPD=OFF, BOREN=OFF, WDTE=OFF, PWRTE=OFF, FOSC=INTRCIO

#define _XTAL_FREQ 4000000

void sys_init(void) {
    TRISIO = 0b011000;    //GP0, 1, 2 output, GP3 & 4 input
    GPIO = 0;
    GIE = 0;
    OPTION_REG = 0x00;  //global enable WPU
    WPU = 0b00110000;    //enable WPU on GP4 (N/A on GP3)
}

void main(void) {
    sys_init();
    while (1) {
        int i = 0;

        for (i = 0; i < 10; i++) {
            GPIO = 0b010011; //drop GP2,GP0, raise GP1
            __delay_ms(150);
            GPIO = 0b010101; //drop GP1, raise GP2
            __delay_ms(150);
        }

        while (GPIObits.GP4 == 1)    //wait until GP4 goes low
            ;
        while (GPIObits.GP4 == 0)    //wait until GP4 goes high
            ;
    }
}
Latest test project, an LED matrix display made from one reel of addressable LEDs. here
User avatar
ric
Verified identity
 
Posts: 453
Joined: Sat May 24, 2014 2:35 pm
Location: Melbourne, Australia
PIC experience: Professional 5+ years with MCHP products

Previous

Return to 14-Bit Core

Who is online

Users browsing this forum: No registered users and 1 guest