SHOW:
|
|
- or go back to the newest paste.
1 | #if defined(__dsPIC33F__) | |
2 | #include "p33Fxxxx.h" | |
3 | #elif defined(__PIC24H__) | |
4 | #include "p24Hxxxx.h" | |
5 | #endif | |
6 | ||
7 | #include "math.h" | |
8 | #define PI 3.14159265358979323846 | |
9 | ||
10 | // Internal FRC Oscillator | |
11 | _FOSCSEL(FNOSC_FRC) | |
12 | _FOSC(FCKSM_CSECMD & OSCIOFNC_OFF & POSCMD_NONE) | |
13 | _FWDT(FWDTEN_OFF) | |
14 | _FICD(ICS_PGD3) | |
15 | ||
16 | void initPLL(void) | |
17 | { | |
18 | PLLFBD = 41; | |
19 | CLKDIVbits.PLLPOST = 0; | |
20 | CLKDIVbits.PLLPRE = 0; | |
21 | OSCTUN = 0; | |
22 | RCONbits.SWDTEN=0; | |
23 | __builtin_write_OSCCONH(0x01); | |
24 | __builtin_write_OSCCONL(0x01); | |
25 | while (OSCCONbits.COSC != 0b001); | |
26 | while(OSCCONbits.LOCK != 1) {}; | |
27 | } | |
28 | ||
29 | int main(void) | |
30 | { | |
31 | initPLL(); | |
32 | float i = 0; | |
33 | float j = 0; | |
34 | float sinArray[100] = {}; | |
35 | unsigned int count = 0; | |
36 | i = 2*PI*0.25; | |
37 | while(count < 20000) | |
38 | { | |
39 | j = sin(i); // Result should be 1; | |
40 | count++; | |
41 | } | |
42 | int breakhere = 1; | |
43 | breakhere = 2; | |
44 | breakhere = 3; | |
45 | breakhere = 4; | |
46 | breakhere = 5; | |
47 | } |