File: C:\Mariano\Temp\SLUG_Autopilot\Stable\controlMCUSlugsMKII_dspic\sources\controlMCUSlugsMKII_main.c1 /* 2 * File: controlMCUSlugsMKII_main.c 3 * 4 * Real-Time Workshop code generated for Simulink model controlMCUSlugsMKII. 5 * 6 * Model version : 1.716 7 * Real-Time Workshop file version : 6.6 (R2007a) 01-Feb-2007 8 * Real-Time Workshop file generated on : Sat Nov 27 11:43:56 2010 9 * TLC version : 6.6 (Jan 16 2007) 10 * C source code generated on : Sat Nov 27 11:43:58 2010 11 *-------------------------------------------------------------- 12 * Embedded Coder for Microchip dsPIC family. | 13 * Generate .c and .h files from your Matlab/simulink model | 14 * and compile the diagram to .hex and .coff file that can be | 15 * downloaded directly into the microcontroller | 16 * | 17 * Licence Accorded to Mariano I. Lizarraga | 18 * University of California Santa Cruz (UCSC)| 19 * | 20 * Written by Lubin KERHUEL - http://www.kerhuel.eu | 21 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | 22 * Version 0.99b+ 17-Mar-2009 | 23 * For Matlab 7.4 R2007a | 24 *-------------------------------------------------------------- 25 */ 26 27 #include "controlMCUSlugsMKII.h" 28 #include "controlMCUSlugsMKII_private.h" 29 30 _FSS( RSS_NO_RAM & SSS_NO_FLASH & SWRP_WRPROTECT_OFF ) 31 _FGS( GCP_OFF & GSS_OFF & GWRP_OFF ) 32 _FOSCSEL( FNOSC_PRIPLL & IESO_OFF & 0xFFFF ) 33 _FOSC( FCKSM_CSDCMD & OSCIOFNC_OFF & POSCMD_EC) 34 _FPOR( FPWRT_PWR64 ) 35 _FWDT( FWDTEN_OFF ) 36 unsigned int CalculusTimeStep; 37 void rt_OneStep() 38 { 39 boolean_T eventFlags[2]; 40 int_T i; 41 42 /* Disable interrupts here */ 43 /* Save FPU context here (if necessary) */ 44 /* Re-enable timer or interrupt here */ 45 controlMCUSlugsMKII_SetEventsForThisBaseStep(eventFlags); 46 controlMCUSlugsMKII_step(0); 47 for (i = 1; i < 2; i++) { 48 if (eventFlags[i]) { 49 controlMCUSlugsMKII_step(i); 50 } 51 } 52 53 /* Disable interrupts here */ 54 /* Restore FPU context here (if necessary) */ 55 /* Enable interrupts here */ 56 } 57 58 int main(void) 59 { 60 PLLFBD = 38; /* configure clock speed */ 61 CLKDIV = 1; 62 63 /* Initialize model */ 64 controlMCUSlugsMKII_initialize(1); 65 66 /* Associate rt_OneStep() with a timer that executes at the base rate of the model */ 67 for (;;) { 68 /* Associate rt_OneStep() with a timer that executes at the base rate of the model */ 69 while (!_T1IF) ; 70 _T1IF = 0; 71 rt_OneStep(); 72 if (_T1IF) 73 CalculusTimeStep = PR1; /* Overload */ 74 else 75 CalculusTimeStep = TMR1; 76 } 77 } 78 79 /* File trailer for Real-Time Workshop generated code. 80 * 81 * [EOF] 82 */ |