-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
54 lines (41 loc) · 1.1 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <xc.h>
#include <stdint.h>
#include <stdio.h>
#include "dsp.h"
#include "adcdac.h"
#include "serial.h"
#include <libpic30.h>
_FOSCSEL(FNOSC_FRCPLL); // Use PLL with oscillator
/**
* Set up PLL for 80 MHz operation.
*/
void pll_init()
{
// Fin = 7.37 MHz
CLKDIVbits.PLLPRE = 0; // (1) Divide by (PLLPRE+2)
PLLFBDbits.PLLDIV = 38; // (2) Multiply by (PLLDIV+2)
CLKDIVbits.PLLPOST = 0; // (3) Divide by 2*(PLLPOST+1)
// 7.37e6 * 40/(2*2): 73.7 MHz
while (OSCCONbits.LOCK != 1); // Wait for PLL to lock
RCONbits.SWDTEN = 0; // Disable Watch Dog Timer
}
int main(void)
{
pll_init();
adc_init();
dac_init();
dma0_init();
timer3_init();
serial_init();
serial_writeln("Starting...");
char msg[81];
extern int samplemax;
while (1) {
// Interrupt driven execution.
// Debug printing done here.
/* sprintf(msg, "Sample Max: %d", samplemax); */
/* serial_writeln(msg); */
/* __delay_ms(1000); */
}
return 0;
}