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

Some basic questions regarding T States

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



Joined: 13 Jan 2007
Posts: 91

View user's profile Send private message Visit poster's website

Some basic questions regarding T States
PostPosted: Mon Aug 10, 2009 1:57 pm     Reply with quote

I am using CCS PCH 4.084, PIC18F2550.

With this at mind :

1. Is a 32Mhz INTRC possible on a PIC18F2550?

Tried doing it and everything started to run almost 4 times as slow compared to when I ran it @8MHz

I can only visually watch the delays of ~1 sec that blinked LEDs.
With an 8MHz INTRC, the timings seem to bo correct though.

I was careful in :

i. setting the #use delay(clock=8000000) and #use delay(clock=32000000) as applicable.
ii. setting the setup_oscillator(OSC_8MHZ | OSC_INTRC); and setup_oscillator(OSC_32MHZ | OSC_INTRC); respectively

2. Is there any easy/quick way of knowing how many T states a C function (say the CCS Standard library function) takes?

I mean - not looking at the code (I believe that CCS Standard library functions may not figure in the ASM list at all maybe?)

3. Are there any PIC18F instructions that can take variable number of T States for the same operands?

4. Regarding Timer0, does it seem to be the case that either CCS or (maybe!) PIC18F itself does not have "auto reload" of the preload value so that I need not do that explicitly everytime I have a timer overflow?

This would seriously hamper my design as I am sure there would be jitter between the timer overflowing and me setting the overflow value (probability increases as time period decreases!)

Because of this, what I am speaking aloud to myself "PIC does not have automatic timer0 reload?! Even the near obsolete 8051 has this."

"Bonus" questions:

6. Can the index of a CCS array for a PIC18F be:
i. int16
ii. int32

7. I connected a 8E (Ohm) speaker to RB3 to listen to some audible square waves. It looks like after I increase the duty cycle (transferred power) of the output signal to a certain higer value, there is complete silence and NO MORE sound seems to come out.

First time I believed that I had burnt the pin, but I can reproduce this any time! Is there some "protective feature" in the PIC that turns off a pin/port/PIC if too much current/power is drawn from a pin/port?

That would be all (or should I have created a separate thread for each post instead?)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 10, 2009 2:13 pm     Reply with quote

Most of this can be answered by looking at the PIC data sheet.
There's a block diagram of the oscillator in the data sheet:
Quote:
FIGURE 2-1: PIC18F2455/2550/4455/4550 CLOCK DIAGRAM

I don't see a path from the INTRC oscillator to the PLL.

To measure the time required for a block of code, use the MPLAB
Simulator's Stopwatch feature. This thread has instructions on how to do it:
http://www.ccsinfo.com/forum/viewtopic.php?t=38351
vsmguy



Joined: 13 Jan 2007
Posts: 91

View user's profile Send private message Visit poster's website

PostPosted: Mon Aug 10, 2009 5:36 pm     Reply with quote

Thanks for the quick reply, and congrats on the milestone of 10k+ posts!

I would like some answers to the other questions though, specially 4 onwards!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 10, 2009 5:47 pm     Reply with quote

What about reading the data sheet ?

Read the section on Timer 2:
Quote:
13.1 Timer2 Operation

In normal operation, TMR2 is incremented from 00h on
each clock (FOSC/4).

The value of TMR2 is compared to that of the period register,
PR2, on each clock cycle. When the two values match,
the comparator generates a match signal as the timer
output. This signal also resets the value of TMR2 to 00h
on the next cycle.

That's how Microchip describes a self-resetting counter.

Do you see a similar description for Timer 0 ?
ckielstra



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

View user's profile Send private message

PostPosted: Mon Aug 10, 2009 6:24 pm     Reply with quote

Question 6) Yes, int16 and int32 can be used as an index, I think. You can check this yourself with a tiny test program and studying the generated assembly output from the *.lst file.
Int32 does not make a lot of sense because of the limited memory capacity. An int16 will address 64k bytes. The PIC18 has maximum 4k RAM.
The PIC processor is not efficient in index based addressing, it creates a lot of overhead, so use with care.

7) Complete silence == PIC death.
Again, read the datasheet and do the maths.
vsmguy



Joined: 13 Jan 2007
Posts: 91

View user's profile Send private message Visit poster's website

PostPosted: Mon Aug 10, 2009 7:46 pm     Reply with quote

ckielstra wrote:

7) Complete silence == PIC death.


That's what I am wondering .. the PIC should have been dead or something?

Then why does it still continue to run after I simply reconnect the power supply .. and that too on the same pin?

Any ideas on how I can find out WHAT is happening - WHY the PIC goes silent (obviously it does not die)?

ckielstra wrote:

Again, read the datasheet and do the maths.


Yes, both you guys, thanks a lot for help! I will read the datasheet in the evening when I have more time.
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