32 lines
698 B
C
32 lines
698 B
C
//
|
|
// PIC12F675 example: blink an LED on pin GP5
|
|
// Written by Ted Burke - 18-2-2017
|
|
//
|
|
// To compile:
|
|
//
|
|
// xc8 --chip=12F675 main.c
|
|
//
|
|
|
|
#include <xc.h>
|
|
#include <stdio.h>
|
|
#include <stdint.h>
|
|
#define DUTY_CYCLE_HIGH .6
|
|
#define DUTY_CYCLE_LOW (1 - DUTY_CYCLE_HIGH)
|
|
#define PERIOD 110 // in microseconds
|
|
#define OFFSET 2
|
|
#define DDR (volatile uint8_t*) 0x00000085
|
|
#define PIN6 1
|
|
|
|
void main(void)
|
|
{
|
|
|
|
*DDR &= ~(1 << PIN6);
|
|
|
|
while(1)
|
|
{
|
|
GP1 = 1; // Set pin GP5 high
|
|
_delay(PERIOD * DUTY_CYCLE_HIGH + OFFSET); // 0.5 second delay
|
|
GP1 = 0; // Set pin GP5 low
|
|
_delay(PERIOD * DUTY_CYCLE_LOW - OFFSET); // 0.5 second delay
|
|
}
|
|
} |