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

On the #use delay in PIC24FJ128 chips.

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



Joined: 21 Jul 2008
Posts: 15
Location: Shanghai, China

View user's profile Send private message

On the #use delay in PIC24FJ128 chips.
PostPosted: Wed Dec 10, 2008 5:04 am     Reply with quote

Hello, all,

I am working on the firmware building on PIC24FJ128GA106 in Mplab IDE 8.15a with Ccsc.exe Rev 4.080 compiler calling.

I have added only the main.c into the source file directory.

And I build a tiny test code for the #use delay , but it seemed that something stranger has happened.

The following code could be compiled and downloaded into the chip successfully.

But when I run the code step by step, the process would always be sticked to the statement--#use delay(clock=20M,oscillator)


And I met it also in my firmware. Also, I run this code continuously, it seems that the code is running in a loop.

Could anybody help me out ?
Code:

#include "24FJ128GA106.h"
#fuses HS, WDT, DEBUG, NOPROTECT, NOJTAG, NOPR, IOL1WAY
#use delay(clock=20M,oscillator)

void main()
{
int c=0;

do
{
   delay_ms(50);
   c++;
}
while(1);   
}

One more question, I am confused on the Watchdog Timer configuration in PIC24F chips.

Accroding to the help file, the WDT in PIC24 family chips should used as following,

the PCH family

Enable/Disable #fuses
Timeout time #fuses
restart restart_wdt();

But , in the 24FJ128GA106.h, the WDT-related configurations are listed below,

// Watch Dog Timer Functions: SETUP_WDT() and RESTART_WDT()
//
// Constants used for SETUP_WDT() are:
#define WDT_ON 1
#define WDT_OFF 0

My question is what about the WDT timeout setting and how to configure the WDT if I use an external 20M crystal.

Thanks in advance.
_________________
Don Quixote
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Wed Dec 10, 2008 10:26 am     Reply with quote

As a general comment, it' aways recommended to read the hardware manuals to better understand the available CPU resources. PIC24 watchdog timing is defined by fuses, which is to my opinion, a feature to make it fail-safe.

Do you mean, that the main loop is never entered? I never tried to step over #use delay, however. What's the purpose of type oscillator in combination with #fuses HS?

P.S.: I see, that you enabled the watchdog in fuses (which means, it is unremovable by code), but don't retrigger the watchdog. You may wan't to include a RESTART_WDT option in #use delay or a NOWDT fuses setting, at least for trial.
donquixote



Joined: 21 Jul 2008
Posts: 15
Location: Shanghai, China

View user's profile Send private message

PostPosted: Wed Dec 10, 2008 7:50 pm     Reply with quote

FvM wrote:
As a general comment, it' aways recommended to read the hardware manuals to better understand the available CPU resources. PIC24 watchdog timing is defined by fuses, which is to my opinion, a feature to make it fail-safe.

Do you mean, that the main loop is never entered? I never tried to step over #use delay, however. What's the purpose of type oscillator in combination with #fuses HS?

P.S.: I see, that you enabled the watchdog in fuses (which means, it is unremovable by code), but don't retrigger the watchdog. You may wan't to include a RESTART_WDT option in #use delay or a NOWDT fuses setting, at least for trial.


Hello, FvM,

Thanks for your comments.

I use oscillator in the #fuses statement since it is recommended in the user manual in PIC24F family, listed as following,

//the following 4 examples all configure the timing library

//to use a 20Mhz clock, where the source is an oscillator.

#use delay (clock=20000000) //user must manually set HS config bit

#use delay (clock=20,000,000) //user must manually set HS config bit

#use delay(clock=20M) //user must manually set HS config bit

#use delay(clock=20M, oscillator) //compiler will set HS config bit

#use delay(oscillator=20M) //compiler will set HS config bit

My puzzle is if I call the delay function in source code and run the code stepwise, so the #use delay statement would be excuted repeatedly. And the rest instructions behind the delay_ms() calling could not be excuted.

Regards,
_________________
Don Quixote
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Dec 11, 2008 12:29 am     Reply with quote

I see, that it's written in the PCD manual, but I can't see any effect of the example #use delay statements on configuration bits or oscillator configuration with PCD V4.083 and PIC24FJ128GA106. The manual examples seems to illustrate an unimplemented feature or hot air.

Actually, it's sufficient to set #fuses HS as you did.

I expect, that the reported issue is caused by your watchdog settings, as said.
donquixote



Joined: 21 Jul 2008
Posts: 15
Location: Shanghai, China

View user's profile Send private message

PostPosted: Thu Dec 11, 2008 2:15 am     Reply with quote

FvM wrote:
I see, that it's written in the PCD manual, but I can't see any effect of the example #use delay statements on configuration bits or oscillator configuration with PCD V4.083 and PIC24FJ128GA106. The manual examples seems to illustrate an unimplemented feature or hot air.

Actually, it's sufficient to set #fuses HS as you did.

I expect, that the reported issue is caused by your watchdog settings, as said.


Hello, FvM,

Thanks. I agreed with you that the manual make me frustrated, some examples of which would be reported error via CCS compiler.

Because my ICD-U40 is broken down, so I am trying to compile the code with Ccsc.exe in Mplab IDE and download via ICD2.

But it seems that something abnormal in using #use delay statement in Mplab IDE with Ccsc.exe calling, and I have built the test code with PIC16F877A. I met the same trouble.

It seems that it is necessary for me to test & verify most of the instructions to make them could work.

Maybe many bugs in supporting PIC24 family chips. Who knows.

I am keeping testing.

Thanks & Regards,
_________________
Don Quixote
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Dec 11, 2008 5:16 am     Reply with quote

It's true, that PCD has still many bugs. But basic operations, as you're performing them, have been always working, at least since V4.079, which I started with. I'm using exactly the same part, and don't see a problem so far, except for the said necessity to either disable the watchdog or to trigger it.

I've been using MPLAB and ICD2 with PIC24F from the beginning, it has been very helpful in locating PCD bugs in assembly level debugger. By the way, you most likely had get more frustrated with PIC24F, if your ICD-U40 would be O.K....

The apparently missing evaluation of some #use delay() options seems to be a minor PCD bug, but if you set the oscillator options through fuses correctly, it doesn't matter, I think. I wasn't aware of it, yet.

Not to run in any debugger error traps, I suggest to write a simple test application, that also does some perceptible things, e. g. blink a LED. You may proceed to "Hello PCD world" then ...
donquixote



Joined: 21 Jul 2008
Posts: 15
Location: Shanghai, China

View user's profile Send private message

PostPosted: Thu Dec 11, 2008 5:28 am     Reply with quote

FvM wrote:
It's true, that PCD has still many bugs. But basic operations, as you're performing them, have been always working, at least since V4.079, which I started with. I'm using exactly the same part, and don't see a problem so far, except for the said necessity to either disable the watchdog or to trigger it.

I've been using MPLAB and ICD2 with PIC24F from the beginning, it has been very helpful in locating PCD bugs in assembly level debugger. By the way, you most likely had get more frustrated with PIC24F, if your ICD-U40 would be O.K....

The apparently missing evaluation of some #use delay() options seems to be a minor PCD bug, but if you set the oscillator options through fuses correctly, it doesn't matter, I think. I wasn't aware of it, yet.

Not to run in any debugger error traps, I suggest to write a simple test application, that also does some perceptible things, e. g. blink a LED. You may proceed to "Hello PCD world" then ...


Hello, FvM,

Heartfelt thanks,

I would like to verify the code again.

Hopefully I could get some helpful suggestions from you in the future.

Regards,
_________________
Don Quixote
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