Advertisement
Guest User

Untitled

a guest
Jul 11th, 2012
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.27 KB | None | 0 0
  1. #if defined(__dsPIC33F__)
  2. #include "p33Fxxxx.h"
  3. #elif defined(__PIC24H__)
  4. #include "p24Hxxxx.h"
  5. #endif
  6.  
  7. #include "dsp.h"
  8. #define n 15
  9. //#define PI 3.14159265358979323846
  10.  
  11. // Internal FRC Oscillator
  12. _FOSCSEL(FNOSC_FRC)
  13. _FOSC(FCKSM_CSECMD & OSCIOFNC_OFF & POSCMD_NONE)
  14. _FWDT(FWDTEN_OFF)
  15. _FICD(ICS_PGD3)
  16.  
  17. void initPLL(void)
  18. {
  19.     CLKDIVbits.PLLPRE = 0;
  20.     PLLFBD = 41;    //M = 43
  21.     CLKDIVbits.PLLPOST = 0;
  22.     OSCTUN = 0;
  23.     RCONbits.SWDTEN=0;
  24.     __builtin_write_OSCCONH(0x01);
  25.     __builtin_write_OSCCONL(0x01);
  26.     while (OSCCONbits.COSC != 0b001);
  27.     while(OSCCONbits.LOCK != 1) {};
  28. }
  29.  
  30. volatile float i = 0;
  31. volatile float j = 0;
  32. volatile float k = 0;
  33. volatile float l = 0;
  34. volatile unsigned int m = 2000;
  35. volatile unsigned int v = 0;
  36. volatile unsigned int count = 0;
  37. volatile unsigned int breakhere = 0;
  38.  
  39. int main(void)
  40. {
  41.     initPLL();
  42.  
  43.     i = 2*PI*0.25;
  44.     while(count < 2000)
  45.     {
  46.         j = sin(i*m);
  47.         v += j;
  48.         count++;
  49.         m--;
  50.     }
  51.  
  52.     if (v == j)
  53.     {
  54.         TRISAbits.TRISA4 = 0; //Output
  55.         LATAbits.LATA4 = 1;
  56.     }
  57.  
  58.     breakhere = 1;
  59.     breakhere = 0;
  60.  
  61.     count = 0;
  62.     while(count < 2000)
  63.     {
  64.         k = 2 + 4;
  65.         count++;
  66.     }
  67.  
  68.     breakhere = 2;
  69.     breakhere = 3;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement