|
|
View previous topic :: View next topic |
Author |
Message |
cfernandez
Joined: 18 Oct 2003 Posts: 145
|
Ticks question |
Posted: Mon Sep 15, 2014 5:21 pm |
|
|
Hi,
I am test the 24E512GP806 in 70MIPS. I use this configuration
Code: |
#include <24EP512GP806.h>
#device *=16
#device adc=8
//#device PSV=16
//#device nested_interrupts=TRUE
#device PASS_STRINGS=IN_RAM
#FUSES NOWDT //No Watch Dog Timer
#FUSES CKSFSM //Clock Switching is enabled, fail Safe clock monitor is enabled
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOJTAG //JTAG disabled
#device ICSP=1
#use delay(internal=140000000)
//#use delay( clock=140000000, crystal=10000000, LOCK )
#pin_select U1TX=PIN_F3
#pin_select U1RX=PIN_F2
#pin_select U2TX=PIN_F5
#pin_select U2RX=PIN_F4
#use rs232( UART1, baud=115200, parity=N, bits=8, stream=SERIAL_COM1, errors, DISABLE_INTS )
#use rs232( UART2, baud=115200, parity=N, bits=8, stream=SERIAL_COM2, errors, DISABLE_INTS )
#use timer( TIMER = 1, TICK = 1ms, BITS = 32, ISR )
|
and when compile my example the compiler tell me :
--- Info 300 "D:\PIC24E\main.h" Line 27(1,1): More info: Timer 1 tick time is 930,61 us
But if I compile the same code for the 24F256 in 40MIPS the compile thell me:
--- Info 300 "\Drv\ticks.h" Line 62(1,1): More info: Timer 1 tick time is 819,20 us
Why the tick time is more short in 24F 40MIPS that 24E 70MIPS??
how to verify if the configuration in 24E is really 70MIPS?
Regards |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Tue Sep 16, 2014 12:33 am |
|
|
The tick, will always prefer to use a timer, without using a reload value if possible (easier, and on the PIC18's more accurate - it forgets that the PIC24 can do an accurate reload). Now timer1, is a 16bit timer. Running from Tcy (clock/2), if allowed to count directly from the clock, at 7000000 Hz, with /1 prescaler, it'll tick in 70000000/65536 times per second = 1068 times per second. 0.93622mSec.
On the other PIC at 40Mips, it can't use this, so has to switch to actually setting a reload value. It uses the short-cut method, that also works on PIC18's, of setting the top bit in the interrupt, so counting 32768 cycles, which then gives 40000000/32768 = 1220.7 times per second = 0.8192mSec.
It does this to avoid any problem with a reload, 'missing' counts that have happened when the handler is called. A legacy from chips like the PIC16/18, which don't have hardware reload on the timers.
Personally, I always want to know exactly what my timers are doing, so would set them up manually. Relying on the automated short-cut, leaves you with questions exactly like yours. 'Why has it chosen this value".
The way to know what clock you chip actually is running, is to do the old 'flash an LED' test. However the timer values make perfect sense for the clock rates. |
|
|
Torello
Joined: 29 Sep 2006 Posts: 120
|
|
Posted: Tue Sep 16, 2014 3:11 am |
|
|
To get my Pic24 running at 32Mhz only the below setup worked. maybe this is also the case in your PIC?
To check if the PIC is running at 32Mhz I used a scope.
Code: |
#include <24FJ128GC006.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES NOJTAG //JTAG disabled
#device ICSP=1
#fuses FRC_PLL
#fuses PLL1
#use delay(clock=32Mhz) //Don't use Internal=32Mhz !!
void main()
{
while(TRUE)
{
output_high(pin_E5);
output_low(pin_E5);
output_high(pin_E5);
output_low(pin_E5);
output_high(pin_E5);
output_low(pin_E5);
output_high(pin_E5);
output_low(pin_E5);
}
} |
_________________ Regards, Edwin. PCWHD v5.114 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Tue Sep 16, 2014 4:14 am |
|
|
Unfortunately, this is not a very good test.
You will need to know exactly how many instructions each output command takes, to work out if the chip is actually clocking at the rate required.
This is why the 'flash an LED' (or feed the same signal to a scope), test is better. What you do is simply:
Code: |
void main()
{
while(TRUE)
{
output_toggle(pin_E5);
delay_ms(1000);
}
}
|
Then since the delay, is determined by the clock setting, if the chip is running at the expected speed, the line will toggle every second. If it toggles every two seconds, you know the chip is at half the expected speed etc..
It is a much repeated 'standard test', that should _always_ be used when starting with a new chip, to verify that your clock settings do work as expected. |
|
|
|
|
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
|