External clock sync
I have a PIC18F26K22. The code I have seems to run at the desired rate. Its using an external clock as its input source.
I think I have a timing issue somewhere along the way (sending data). It results in some data being sent too quickly at times or too slow. (This happens after a minute or so)
Is there a way to ensure the input clock is synced to the internal clocks ?
Currently my config is this :
#pragma config FOSC = ECMP // Oscillator Selection bits (Internal oscillator block)
#pragma config PLLCFG = OFF // 4X PLL Enable (Oscillator used directly)
#pragma config PRICLKEN = ON // Primary clock enable bit (Primary clock is always enabled)
#pragma config FCMEN = OFF // Fail-Safe Clock Monitor Enable bit (Fail-Safe Clock Monitor disabled)
#pragma config IESO = OFF // Internal/External Oscillator Switchover bit (Oscillator Switchover mode disabled)
#pragma config PWRTEN = OFF // Power-up Timer Enable bit (Power up timer disabled)
#pragma config BOREN = OFF // Brown-out Reset Enable bits (Brown-out Reset enabled in hardware only (SBOREN is disabled))
#pragma config WDTEN = OFF // Watchdog Timer Enable bits (Watch dog timer is always disabled. SWDTEN has no effect.)
//#pragma config WDTPS = OFF // Watchdog Timer Postscale Select bits (1:32768)
#pragma config MCLRE = EXTMCLR // MCLR Pin Enable bit (MCLR pin enabled, RE3 input pin disabled)
#define _XTAL_FREQ 4500000UL
I read somewhere I can set certain bits but not sure ? (T1SYNC )
Is there a way to check wait for a clock edge then perform an action ? (INTEDG) Timer0 ?
Im looking at - but its beyond me at the moment. http://ww1.microchip.com/downloads/en/DeviceDoc/31011a.pdf