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

18F4431 - setup_timer_5() is not documented...
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
LloydSargent



Joined: 11 Jun 2004
Posts: 13

View user's profile Send private message

PostPosted: Mon Jun 14, 2004 12:08 pm     Reply with quote

<drum roll>

Okay, here is the answer:

When using a 18F4431 attempting to use the function setup_timer_5() does not work.

What does work is setup_timer_4(mode, period, postscale)... Except it doesn't. Apparently this code was never really FULLY completed. It DOES write the mode to T5CON. That is a good thing.

HOWEVER, it does not write the period. A very bad thing. Worse, there IS no postscale on Timer 5!

Oh, well, so much for pathos...

Cheers,

Lloyd
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jun 14, 2004 12:09 pm     Reply with quote

You forgot one possible answer:
d) Timer 5 has a new format.

Sorry, you never mentioned which compiler version you have, but I guess it is one of the latest versions. I have v3.187 from a few months ago and that version doesn't support your chip. So, you will not like this, but it looks like you are the first one to test the Timer5 functionality. Consider it a Beta release....

Looking at the specs for the Timer5 it requires settings that are somewhere in between the functionality of Timer1 and Timer2. Timer5 has a period value but doesn't have a postscaler.

CCS is (again) sloppy with their documentation, but doing an educated guess I would try the following format:

setup_timer_5(mode, period)
Code:
setup_timer_5(T5_INTERNAL, 0x1234)
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jun 14, 2004 12:17 pm     Reply with quote

Do you know there is a utility for setting the device configurations? It is called chipedit.exe and is located in the same directory as your compiler. I'm curious whether CCS has configured the PIC18F4431 correctly here (I have an older version of the compiler than you have, so can't check it myself).
LloydSargent



Joined: 11 Jun 2004
Posts: 13

View user's profile Send private message

PostPosted: Mon Jun 14, 2004 12:27 pm     Reply with quote

ckielstra wrote:
Do you know there is a utility for setting the device configurations? It is called chipedit.exe and is located in the same directory as your compiler. I'm curious whether CCS has configured the PIC18F4431 correctly here (I have an older version of the compiler than you have, so can't check it myself).


We only bought the PCH compiler and it looks like ChipEdit.exe isn't part of that (looked after I saw another post about ChipEdit). Must only come with the full package.

Cheers,

Lloyd
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Mon Jun 14, 2004 1:04 pm     Reply with quote

I think you have put enough time into this. Mail your question to CCS, often you get a response within a day. Please post the answer you get here in the forum.
LloydSargent



Joined: 11 Jun 2004
Posts: 13

View user's profile Send private message

PostPosted: Mon Jun 14, 2004 1:15 pm     Reply with quote

ckielstra wrote:
I think you have put enough time into this. Mail your question to CCS, often you get a response within a day. Please post the answer you get here in the forum.


Sent it in Friday. Was hoping on an answer today.

In the meanwhile just built a function that did the same thing. Took ten minutes (including testing).

Cheers,

Lloyd
MGP



Joined: 11 Sep 2003
Posts: 57

View user's profile Send private message

PostPosted: Mon Jun 14, 2004 1:16 pm     Reply with quote

This is a totally "left field" question, but do you have your compiler options set for "case sensitive"?

I noticed in the CCS header file you posted that the function names are all CAPS. If they are truly that way in the CCS library and you have case sensitivity turned on, the compiler would reject any of the different options you tried, yes?

Like I said, just a quick thought on something that's caught me out before...
MGP



Joined: 11 Sep 2003
Posts: 57

View user's profile Send private message

PostPosted: Mon Jun 14, 2004 1:18 pm     Reply with quote

uhhh... nevermind. I was slow in posting my response. Embarassed
uController
Guest







PostPosted: Wed Nov 10, 2004 12:05 am     Reply with quote

Any answer from CCS on this yet?
If not I will call them and compain. (again)
Would be nice if they posted these issues and solutions here.
It's very frusterating developing a simple microcontroller project
and constantly woundering if I made a mistake or is a compiler
problem. Confused
I would be hung if I produced software like this.

Thanks for all the help everyone,
uC
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Nov 11, 2004 4:03 am     Reply with quote

See the release notes:
Quote:
3.204 Support for Timer 5 added
uController
Guest







PostPosted: Thu Nov 11, 2004 4:00 pm     Reply with quote

I am using V3.212 which is the latest.
Same problem.
Any other suggestions?

Here is how I am trying to implement it;
setup_timer_5(T5_INTERNAL | T5_DIV_BY_1);

Here is the error;
Undefined identifier setup_timer_5

Here is the header info;
// Timer 5 Functions: SETUP_TIMER_5, GET_TIMER5, SET_TIMER5
// Constants used for SETUP_TIMER_5() are:
// (or (via |) together constants from each group)
#define T5_DISABLED 0
#define T5_INTERNAL 0x01
#define T5_EXTERNAL 0x07
#define T5_EXTERNAL_SYNC 0x03

#define T5_DIV_BY_1 0
#define T5_DIV_BY_2 0x08
#define T5_DIV_BY_4 0x10
#define T5_DIV_BY_8 0x18

#define T5_ONE_SHOT 0x20

#define T5_DISABLE_SE_RESET 0x40

#define T5_ENABLE_DURING_SLEEP 0x80


I suppose I wil just have to call them. (AGAIN!!!) Crying or Very sad
I spend more time on the phone with them debugging the compiler
than writing code. This is very disappointing! Crying or Very sad

Thanks,
uC
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 11, 2004 4:27 pm     Reply with quote

When the compiler doesn't support some function that you need,
then you should write it yourself. This is done by defining the
register addresses with #byte statements (and possibly some
bits with #bit statements) and then by writing a function or macro
to set the registers to the appropriate values. You consult the
data sheet and also look at the ASM code for similar functions
that do compile properly. Use those as a guide to writing
your own functions.

In the example below, I have written a macro to emulate the
CCS setup_timer_5() function, which is apparently not supported yet.


#include <18F4431.H>
#fuses XT, PUT, BROWNOUT, NOWDT, NOLVP
#use delay(clock=4000000)

#byte T5CON = 0xFB7

#define setup_timer_5(mode) T5CON = (mode)

//==================================
void main()
{

setup_timer_5(T5_INTERNAL | T5_DIV_BY_1);

while(1);
}


//=================================
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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