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 support@ccsinfo.com

Why has H4 Use not effect ? Please need explanation !

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



Joined: 25 Oct 2004
Posts: 136

View user's profile Send private message

Why has H4 Use not effect ? Please need explanation !
PostPosted: Sat Jan 27, 2007 5:32 am     Reply with quote

Hi Friends !

I'am working now since 2 years with the CCS Compiler and discovered now a very odd problem:

Code:

#include <18F8720.h>

#device ICD=TRUE
#device adc=8
#device *=16

#use delay(clock=  8000000)
//#use delay(clock=  32000000)

#fuses NOWDT,WDT128,H4, NOPROTECT, NOOSCSEN, BROWNOUT, BORV25, PUT, NOCPD, STVREN, DEBUG, NOLVP, NOWRT, NOWRTD, NOWAIT, MCU, NOWRTC, NOWRTB, NOEBTR, NOEBTRB, NOCPB

#use rs232(baud=38400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=com1,errors)

#define TEST PIN_A3

#include <stdio.h>


//--------------------------------
#int_timer3
void timer3_isr()
{
set_timer3(0xF830);
//output_toggle(test);
}

//--------------------------------
void main()
{
   setup_wdt(WDT_OFF);
   setup_timer_0(RTCC_INTERNAL);
   setup_timer_2(T2_DIV_BY_16,0xFF,8);
   setup_timer_3(T3_INTERNAL|T3_DIV_BY_1);
   setup_vref(FALSE);
   set_timer3(0xF830);         // Setup Timer3 as ms Timer @ 32 MHz


fprintf(com1,"Test Message at COM1 @38400 Bd ???\n\r");
enable_interrupts(int_timer3);
enable_interrupts(global);

//--------------------------------
while(1)                         // MAIN LOOP Starts Here
{
output_toggle(test);
delay_ms(1);
output_toggle(test);

} //while(1)
} //main


This code works fine, execpt I am expecting the CPU to run at 32MHz with a 8MHz Quarz !!!!

But as You can see the delay directive says 8MHz !! The baudrate and the delay is working correct with this settings.

Where to I miss the point for using the x4 PLL ????

Anybody out there has an idea ??

best regards and greetings from vienna

Andreas
 
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Sat Jan 27, 2007 7:07 am     Reply with quote

You must specify 32000000 in the use delay. Also, the first time you set the H4 fuse, you must power off the board and then back on. Search the forum and you will find many examples of the same problem.
Andreas



Joined: 25 Oct 2004
Posts: 136

View user's profile Send private message

PostPosted: Sat Jan 27, 2007 12:20 pm     Reply with quote

Hello Mark !

Thanks a lot for Your fast reply !

Of course this was the problem, now looking in the past I could remember that I had sometimes this behaviour and it was gone somewhere, because I must have powered down the device at night time !!!

I am now trying to find a note at the microchip decsheets

Thanks and best regards
Andreas
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