Manu Abraham | 10 May 2012 21:43
Picon

Re: [PIC] 18F4550 and OSCCON and Tcy

On Fri, May 11, 2012 at 1:04 AM, Manu Abraham <abraham.manu@...> wrote:
> On Fri, May 11, 2012 at 12:50 AM, Bob Ammerman <picram@...> wrote:
>>> Hi,
>>>
>>> I have my config fuses thus with a 20MHz XTAL connected
>>>
>>> #pragma config FOSC = INTOSC_HS
>>> #pragma config PWRT = OFF
>>> #pragma config BOR = OFF
>>> #pragma config MCLRE = ON
>>> #pragma config PBADEN = OFF
>>> #pragma config ICPRT = OFF
>>> #pragma config LVP = OFF
>>> #pragma config WDT = OFF
>>>
>>> and a simple snippet as follows ..
>>>
>>> void main()
>>> {
>>> OSCCON = 0x72; /* 8MHz INTOSC drives clock directly */
>>> OSCTUNE = 0x80; /* 31.25 kHz device clock derived from 8 MHz INTOSC */
>>>
>>> while (1) {
>>> Nop(); // this took .2uS or 200nS
>>> Delay10TCYx(120); // this took 481.2 uS
>>>        }
>>> }
>>>
>>> With the simulator trace, I am viewing the elapsed time for each
>>> instruction.
>>>
>>> Prior to OSCCON setup to 0x72, OSCCON was defaulting to 0x00 implying
>>> 1MHz INTOSC driven clock.
>>>
>>> The trace showed an elapsed time period of 0.2uS at 1MHz. Even after
>>> OSCCON was set to 8MHz INTOSC clock, I still do see the elapsed Tcy
>>> period as 0.2uS itself.
>>>
>>> Am I missing something ?
>>>
>>> Thanks,
>>> Manu
>>
>> Yes, the simulator only shows the time period based on the clock rate *you
>> enter*. It does not know the current clock rate of the simulated chip.
>>
>> -- Bob Ammerman
>> RAm  Systems
>
>
> The Simulator is set for a 20MHz "Processor frequency" which is same as the
> crystal frequency and the simulator window also shows that.
>
> You meant to change that "Processor frequency" ?

I am a bit confused.

The information here

http://w3.id.tue.nl/fileadmin/id/objects/E-Atelier/doc/Tutorials/DELAY_FUNCTIONS_18F4550.pdf

with a 20MHx crystal,

Delay10TCYx (60); // gives a delay of 10 x 60 x 1/12 = 600/12 = 50 us
This would be 100uS in my case with Delay10TCYx (120) but I am
actually getting a delay of
481uS (Delay10TCYx(120); // this took 481.2 uS)

--

-- 
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist


Gmane