View previous topic :: View next topic |
Author |
Message |
berel
Joined: 20 Oct 2011 Posts: 15
|
PIC18F14K50 slow output speed |
Posted: Thu Oct 20, 2011 2:56 am |
|
|
Hi,
I am using the 18F14K50 with a 12 MHz crystal. When using a minimal program like
Code: |
#include <18F14K50.h>
#fuses HS,NOWDT,NOLVP,NODEBUG,CPUDIV2,PLLEN
#use delay(clock=12M, crystal)
void main() {
setup_ADC( ADC_OFF);
output_low(PIN_C4);
output_high(PIN_C4);
output_low(PIN_C4);
output_high(PIN_C4);
output_low(PIN_C4);
}
|
I see two pulses with a 8 µs width.
But in a code for a USB HID I obtain 340 ns pulses with the same fuses.
I have not found the reason for the "slow" pulses (delay_us also gives too long times).
Can anybody explain it ?
Thanks ! |
|
|
n-squared
Joined: 03 Oct 2006 Posts: 99
|
|
Posted: Thu Oct 20, 2011 3:20 am |
|
|
Hi
You enble the PLL (#fuses PLLEN) but specify clock=12M.
Try:
Code: |
#use delay(clock=48M,crystal=12M)
|
BR
NN _________________ Every solution has a problem. |
|
|
berel
Joined: 20 Oct 2011 Posts: 15
|
|
Posted: Thu Oct 20, 2011 3:44 am |
|
|
Hi n-squared,
thanks for the hint: I tried so, but it did not make a change.
berel |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Oct 20, 2011 12:58 pm |
|
|
Post your CCS compiler version.
It's a 4-digit number (only) given at the start of the .LST file, which will be
in your project directory after you compile a file with no errors.
Example of version numbers:
http://www.ccsinfo.com/devices.php?page=versioninfo
Also, are you aware that your code as posted, does not have a loop,
and it will run one time only. Then it will execute the hidden SLEEP
instruction that CCS puts at the end of main() and it will shut down.
How are you measuring these pulses ? Must be a logic analyzer.
A scope wouldn't see it.
Or, this is a Proteus project. Is it ? |
|
|
berel
Joined: 20 Oct 2011 Posts: 15
|
|
Posted: Fri Oct 21, 2011 12:22 am |
|
|
PCH compiler version is 4.116, used within MPLAB 8.76
The code as posted is just a minimum code for testing. The target code is one for a HID USB device.
I am measuring the pulses with a Saleae logic analyzer as well as a TDS220 scope.
It is not a Proteus project (whatever it is ...).
In the complete code for the USB HID device, I found that a usb_init_cs() in front of the code for the pulses shows the 8 µs pulses again, wheras a usb_init() gives the short 170 ns pulses (CPUDIV1, PLLEN) |
|
|
|