"pragma cpu_fosc" Statement
The "pragma cpu_fosc" statement tells the compiler what the
intended frequency of the CPU clock generating oscillator is. A 4MHz
oscillator is specified as 4000000. This is divided by 4 internally by
the PIC core to produce a 1MHz clock. The compiler uses the cpu_fosc
value to calculate other parameters which are made available to the
programmer, such as:
- hardware timer values (used to generate the required number of heartbeats per second)
- Hardware SPBRG and BRGH values (used to generate the USART clock for user specified baud rates)
- delay_10us timing loop
- delay_1ms timing loop
syntax
pragma cpu_fosc 4000000
The "pragma cpu_fosc" statement provides the oscillator value for
use by the rest of the program through the CPU_FOSC manifest
constant. The programmer may use this constant like any other constant.
e.g.
x = CPU_FOSC / 1000