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

PIC18F14K50 slow output speed

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



Joined: 20 Oct 2011
Posts: 15

View user's profile Send private message

PIC18F14K50 slow output speed
PostPosted: Thu Oct 20, 2011 2:56 am     Reply with quote

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

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Thu Oct 20, 2011 3:20 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Oct 20, 2011 3:44 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Oct 20, 2011 12:58 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri Oct 21, 2011 12:22 am     Reply with quote

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)
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