Created
March 17, 2017 11:55
-
-
Save akimasa/82e78ab4baf76725eafe935eb0437bb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright (C) 2014 Diego Herranz | |
#define NO_BIT_DEFINES | |
//#include <pic14regs.h> | |
#include <pic12lf1822.h> | |
#include <stdint.h> | |
// Oscillator Selection bits (INTOSCIO oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN), | |
// disable watchdog, | |
// and disable low voltage programming. | |
// The rest of fuses are left as default. | |
__code uint16_t __at (_CONFIG1) __configword = _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON; | |
#define LED_PORT PORTAbits.RA2 | |
#define LED_TRIS TRISAbits.TRISA2 | |
// Uncalibrated delay, just waits a number of for-loop iterations | |
void delay(uint16_t iterations) | |
{ | |
uint16_t i; | |
for (i = 0; i < iterations; i++) { | |
// Prevent this loop from being optimized away. | |
__asm nop __endasm; | |
} | |
} | |
void main(void) | |
{ | |
//default 500kHz | |
OSCCONbits.IRCF = 0xf;//16MHz | |
LED_TRIS = 0; // Pin as output | |
LED_PORT = 0; // LED off | |
while (1) { | |
LED_PORT = 1; // LED On | |
delay(300); // ~500ms @ 4MHz | |
LED_PORT = 0; // LED Off | |
delay(300); // ~500ms @ 4MHz | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SRC=blink_led.c | |
CC=sdcc | |
FAMILY=pic14 | |
PROC=12lf1822 | |
all: $(SRC:.c=.hex) | |
$(SRC:.c=.hex): $(SRC) | |
$(CC) --use-non-free -m$(FAMILY) -p$(PROC) $^ | |
clean: | |
rm -f $(SRC:.c=.asm) $(SRC:.c=.cod) $(SRC:.c=.hex) $(SRC:.c=.lst) $(SRC:.c=.o) | |
.PHONY: all clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment