CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Use TIMER4 in CCP module (18F45j50)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
tae



Joined: 15 Jan 2010
Posts: 11

View user's profile Send private message

Use TIMER4 in CCP module (18F45j50)
PostPosted: Wed Jan 19, 2011 11:49 am     Reply with quote

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!
tae



Joined: 15 Jan 2010
Posts: 11

View user's profile Send private message

PostPosted: Wed Jan 19, 2011 12:47 pm     Reply with quote

I figured out !
http://img-fotki.yandex.ru/get/5500/t-a-e.0/0_46980_cbdb9371_L
I add
Code:
#BYTE TCLKCON = 0xF52

TCLKCON = 0b00000010;


CCS has the means to change except through the register TCLKCON ?
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group