00001 /* 00002 * "Copyright (c) 2008 Robert B. Reese, Bryan A. Jones, J. W. Bruce ("AUTHORS")" 00003 * All rights reserved. 00004 * (R. Reese, reese_AT_ece.msstate.edu, Mississippi State University) 00005 * (B. A. Jones, bjones_AT_ece.msstate.edu, Mississippi State University) 00006 * (J. W. Bruce, jwbruce_AT_ece.msstate.edu, Mississippi State University) 00007 * 00008 * Permission to use, copy, modify, and distribute this software and its 00009 * documentation for any purpose, without fee, and without written agreement is 00010 * hereby granted, provided that the above copyright notice, the following 00011 * two paragraphs and the authors appear in all copies of this software. 00012 * 00013 * IN NO EVENT SHALL THE "AUTHORS" BE LIABLE TO ANY PARTY FOR 00014 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT 00015 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE "AUTHORS" 00016 * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00017 * 00018 * THE "AUTHORS" SPECIFICALLY DISCLAIMS ANY WARRANTIES, 00019 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00020 * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS 00021 * ON AN "AS IS" BASIS, AND THE "AUTHORS" HAS NO OBLIGATION TO 00022 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." 00023 * 00024 * Please maintain this header in its entirety when copying/modifying 00025 * these files. 00026 * 00027 * 00028 */ 00029 00030 #include "pic24_all.h" 00031 00043 //a naive software delay function 00044 void a_delay(void) { 00045 uint16 u16_i,u16_k; 00046 // change count values to alter delay 00047 for (u16_k=1800; --u16_k;) { 00048 for (u16_i = 1200 ; --u16_i ;); 00049 } 00050 } 00051 00052 00053 int main(void) { 00054 configClock(); //clock configuration 00055 /********** GPIO config **********/ 00056 #ifdef _ODB15 //PIC24F CPU header files define this instead of ODCB15 00057 _ODB15 = 1; //enable open drain 00058 #else 00059 _ODCB15 = 1; //enable open drain 00060 #endif 00061 _TRISB15 = 0; //Config RB15 as output 00062 _LATB15 = 0; //RB15 initially low 00063 while (1) { //infinite while loop 00064 a_delay(); //call delay function 00065 _LATB15 = !_LATB15; //Toggle LED attached to RB15 00066 } // end while (1) 00067 }