Subversion Repositories HomeAutomation

Rev

Rev 51 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 51 Rev 64
Line 16... Line 16...
16
#include <p18cxxx.h>
16
#include <p18cxxx.h>
17
#define CLOCK_FREQ      (40000000)      // Hz
17
#define CLOCK_FREQ      (40000000)      // Hz
18
#define INSTR_FREQ          (CLOCK_FREQ/4)
18
#define INSTR_FREQ          (CLOCK_FREQ/4)
19
#define CLOCK_FOSC      (40)      // MHz
19
#define CLOCK_FOSC      (40)      // MHz
20
 
20
 
21
#define UART_BAUD_RATE       (19200)     // bps
21
#define UART_BAUD_RATE       (115200)     // bps
-
 
22
#define HIGH_BRG
22
 
23
 
-
 
24
#ifdef HIGH_BRG
-
 
25
    #define SPBRG_VAL   ( ((CLOCK_FREQ/UART_BAUD_RATE)/4) - 1)
-
 
26
    #define SPBRGH_VAL  0
-
 
27
#else
23
#define SPBRG_VAL   ( ((INSTR_FREQ/UART_BAUD_RATE)/16) - 1)
28
    #define SPBRG_VAL   ( ((INSTR_FREQ/UART_BAUD_RATE)/16) - 1)
-
 
29
#endif
-
 
30
 
24
 
31
 
25
#if (SPBRG_VAL > 255)
32
#if (SPBRG_VAL > 255)
26
    #error "Calculated SPBRG value is out of range for currnet CLOCK_FREQ."
33
    #error "Calculated SPBRG value is out of range for currnet CLOCK_FREQ."
27
#endif
34
#endif
28
 
35