tae
Joined: 15 Jan 2010 Posts: 11
|
Use TIMER4 in CCP module (18F45j50) |
Posted: Wed Jan 19, 2011 11:49 am |
|
|
Hello all !
I can not understand how to use Timer4 in module CCP1?
16 MHz crystal.
Code: | #include <18F45J50.h>
#device adc=8
#case
#FUSES NOWDT //No Watch Dog Timer
#FUSES WDT128 //Watch Dog Timer uses 1:128 Postscale
#FUSES PLL4 //Divide By 4(16MHz oscillator input)
#FUSES STVREN //Stack full/underflow will cause reset
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOCPUDIV
//#FUSES CPUDIV6
#FUSES NOPROTECT //Code not protected from reading
#FUSES HSPLL //High Speed Crystal/Resonator with PLL enabled
#FUSES T1DIG
#FUSES LPT1OSC //Timer1 configured for low-power operation
#FUSES NOFCMEN //Fail-safe clock monitor disabled
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES DSWDTOSC_INT
#FUSES RTCOSC_T1
#FUSES DSBOR
#FUSES DSWDT
#FUSES DSWDT2147483648
#FUSES IOL1WAY //Allows only one reconfiguration of peripheral pins
#FUSES MSSPMSK7
#FUSES WPFP
#FUSES WPBEG
#FUSES NOWPCFG
#FUSES WPDIS
#use delay(clock=48000000)
#use i2c(master, sda=PIN_B5, scl=PIN_B4, FAST)
#PIN_SELECT P1A = PIN_D7
setup_oscillator(OSC_PLL_ON | OSC_NORMAL);
setup_timer_0(T0_INTERNAL | T0_DIV_1 | T0_8_BIT);
// setup_timer_2(T2_DIV_BY_16,255,1);
setup_timer_4(T4_DIV_BY_16,255,1);
setup_ccp1(CCP_PWM);
set_pwm1_duty(128);
for(;;) {
}; |
is not work, but if I use TIMER2:
Code: | setup_oscillator(OSC_PLL_ON | OSC_NORMAL);
setup_timer_0(T0_INTERNAL | T0_DIV_1 | T0_8_BIT);
setup_timer_2(T2_DIV_BY_16,255,1);
//setup_timer_4(T4_DIV_BY_16,255,1);
setup_ccp1(CCP_PWM);
set_pwm1_duty(128);
for(;;) {
}; |
it work !
where is my mistake?
Thank you! |
|