File indexing completed on 2025-03-16 08:26:25
0001 // Example taken from 0002 // https://github.com/diegoherranz/sdcc-examples/blob/master/pic14/1.blink_led/blink_led.c 0003 // Copyright (C) 2014 Diego Herranz 0004 // GPLv2 0005 // 0006 /* 0007 0008 Copyright (C) 2014 Diego Herranz 0009 0010 This file is free software: you can redistribute it and/or modify 0011 it under the terms of the GNU General Public License as published by 0012 the Free Software Foundation, either version 2 of the License, or 0013 (at your option) any later version. 0014 0015 Foobar is distributed in the hope that it will be useful, 0016 but WITHOUT ANY WARRANTY; without even the implied warranty of 0017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0018 GNU General Public License for more details. 0019 0020 You should have received a copy of the GNU General Public License 0021 along with Foobar. If not, see <http://www.gnu.org/licenses/>. 0022 */ 0023 0024 #include <pic16regs.h> 0025 #include <stdint.h> 0026 0027 0028 // Uncalibrated delay, just waits a number of for-loop iterations 0029 void delay(uint16_t iterations) 0030 { 0031 uint16_t i; 0032 for (i = 0; i < iterations; i++) { 0033 // Prevent this loop from being optimized away. 0034 __asm nop __endasm; 0035 } 0036 } 0037 0038 int main(void) { 0039 TRISA1 = 0; 0040 while (1) { 0041 RA1 = 1; 0042 delay(1000); 0043 RA1 = 0; 0044 delay(1000); 0045 } 0046 return 0; 0047 }