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

Different speed for different ports
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
RBuilder



Joined: 27 Oct 2011
Posts: 10

View user's profile Send private message

PostPosted: Thu Mar 22, 2012 6:03 am     Reply with quote

PCM programmer wrote:
Quote:
output_high(pin_d7) is slower than output_high(pin_d0) even when in a timer

You should be able to post a super-short compilable test program so
we can test this.


Have you tested the other code from a few posts up with the delay_us? Did you see how the pulse width of pin_d0 is exactly the same for every pulse. And did you notice that the pulse width of pin_d7 is exactly the same for every pulse? And did you notice that D7 pulse is longer than D0 pulse width?

It's nothing to do with counters. If i manually set the bit of that port in assembler with BCF and BSF then it's still the same results. And if you look at the LST, you'll see the BCF and BSF specifically following the return from the delay.

I'm just very surprised none of you have noticed that higher bits of a port are slower than lower bits, even when explicitly setting the bit with BCF or BSF.

I recognize that it is happening, so i've determined a work-around by specifying a different delay for each bit.

Thanks for your assistance
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Thu Mar 22, 2012 9:23 am     Reply with quote

What exactly are you expecting from this? Are you expecting too much? I ask this as you observed this when trying to write a software solution to serial interfacing, which is essentially a hardware problem, and for which most PICs have dedicated and quite versatile hardware.

No output from a processor running code will ever be as precise as a hardware designed solution. All sort of things can interfere with the timing. So even us accurate timing is unlikely to be acheived with a software based solution, and few serious engineers will entertain any notion that is may ever be so.

If there is a timing difference from IO bit to IO bit then I don't even expect that to be the same from example to example of the same PIC let alone different PICs, even in the same family. There's going to be some variation: with voltage, load current, temperature, load capacitance, even track geometry.

All in all, on PICs if a IO bit changes in the us you expect then you're doing OK. Not well I grant you, but OK. When it changes in relation to the internal four phase clock (or two phase for 24s and up) is not specified, and thus I can never rely on it being a) what I want, or b) being the same under a sufficiently wide range of conditions. If that's important I'll use discrete logic or more likely an FPGA.

RF Developer
Ttelmah



Joined: 11 Mar 2010
Posts: 19548

View user's profile Send private message

PostPosted: Thu Mar 22, 2012 9:32 am     Reply with quote

Seriously, have just tested this, and the times are _identical_. Less than 5nSec difference on my DSS.

As said before, I would expect it when using a variable to access the bit, but not when hard coded bit numbers are used. For me, on four separate chips, there is no difference.

Tried with a hardware clock source, feeding a timer, and operating the pin inside the timer ISR, then measured the time between the clock edge, and the pin changing. All varied between 3.3uSec, and 3.4uSec after the clock edge, as the incoming asynchronous clock beat with the instruction clock of the CPU (remember interrupts are serviced on the next T1 state after the event), but the timings were the same whatever port pin was used.

I think you are seeing an artefact caused by something else in your code.

Best Wishes
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Thu Mar 22, 2012 10:49 am     Reply with quote

Quote:

Have you tested the other code from a few posts up with the delay_us? Did you see how the pulse width of pin_d0 is exactly the same for every pulse. And did you notice that the pulse width of pin_d7 is exactly the same for every pulse? And did you notice that D7 pulse is longer than D0 pulse width?

It's nothing to do with counters. If i manually set the bit of that port in assembler with BCF and BSF then it's still the same results. And if you look at the LST, you'll see the BCF and BSF specifically following the return from the delay.

I'm just very surprised none of you have noticed that higher bits of a port are slower than lower bits, even when explicitly setting the bit with BCF or BSF.

If you still have an issue with this, post a really short, complete, compilable program which demonstrates the problem.

Then we can all test it, and confirm your assertion.

Mike
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Fri Mar 23, 2012 3:12 pm     Reply with quote

Code:

#include <18f4610.h>
#include <stdlib.h>
#FUSES NOPROTECT,NOMCLR,HS,NOWDT,NODEBUG,NOLVP,NOIESO,
#fuses NOFCMEN,PUT,NOWRT,NOFCMEN,BROWNOUT,BORV27,
#fuses CCP2C1,NOPBADEN,NOLPT1OSC,noxinst,
#use fast_io(B)
#use fast_io(D)
#use delay( clock=20000000 )
// pin_b1  has 10k pullup external  and jumper switch
// so i can go back and forth between the two port pins
void main(void){
 set_tris_b(0xff);   set_tris_d(0);
 while (1); {
  do{    output_toggle(PIN_D0);    delay_cycles(8);  }while (input(pin_B0));
  do{     output_toggle(PIN_D7);     delay_cycles(8);  }while (!input(pin_B0));
}}



For 18F4610 , with 20 mhz external oscillator

I borrowed a Tek TDS680c from a client , for the week end
and just tried this on one of my ZIF socket development boards.

My testimony is that the variation in observed delay is ALL
dependent on the external oscillator jitter - in the range of +/-1.5 ns
timing jitter attributable to the pic is , IMHO, appx 1.5 ns max.

I don't know what resolution TTELMAHS DSO has , but i find no
disagreement on the core issue: THE PORT PIN YOU USE IS NOT A FACTOR IN ANY DELAY ISSUE , and all port pins on port d are IDENTICAL
when it comes to creation of delays.
( at least when addressed as in the example above).
Are we done now ??

Very Happy Very Happy Very Happy
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Fri Mar 23, 2012 4:04 pm     Reply with quote

I should add - in order to get good crisp transition times - I was reading the port via a series divider from the pins under test, to ground, such that we are operating at appx 2 ma with a 2.4k resistor in series with a 100 ohm resistor to ground. And of course reading the port transitions across the 100 ohm part of the divider. Hopefully this should need no further explanation, right ?
Ttelmah



Joined: 11 Mar 2010
Posts: 19548

View user's profile Send private message

PostPosted: Fri Mar 23, 2012 4:19 pm     Reply with quote

Glad to have it confirmed.

I was expanding the test, using an external clock to feed a timer input, and triggering the pin change inside the timer interrupt, which then adds up to one instruction cycle of jitter as the external clock beats with the internal clock timing (interrupt is serviced at the next instruction's 'first cycle' after it happens). Hence the 0.1uSec of jitter on the results (at 40MHz). However the minimum time, and maximum times, were identical whatever pin I used. Had to sample quite slowly to store a complete cycle of the timer, hence sampled at 200MHz, so 5nSec 'best case' resolution.

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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