gnupic: PIC18F47J53


Previous by date: 12 Aug 2013 21:56:10 -0000 Re: PIC18F47J53, Luis de Arquer
Next by date: 12 Aug 2013 21:56:10 -0000 Re: PIC18F47J53, Luis de Arquer
Previous in thread: 12 Aug 2013 21:56:10 -0000 Re: PIC18F47J53, Luis de Arquer
Next in thread: 12 Aug 2013 21:56:10 -0000 Re: PIC18F47J53, Luis de Arquer

Subject: Re: PIC18F47J53
From: Bob Jacobsen ####@####.####
Date: 12 Aug 2013 21:56:10 -0000
Message-Id: <16739DAB-19C9-4547-B0E9-4E7E4A6A045A@lbl.gov>

On Aug 12, 2013, at 1:09 PM, Luis de Arquer ####@####.#### wrote:

> Problem number 1 is surely a C issue, which is the sleep function I made:
> 
> ****************************
> 
> typedef unsigned char byte;
> 
> void sleep_a_while(byte c)              /* A */
> {
>  byte i,j;                                           /* B */
> 
>  for(i=0; i<200; i++)
>    for(j=0; j<c; j++) ;
> }
> 
> 
> **************************
> 
> Changing "byte" for "int" in any of those lines changes the timing. It
> makes the sleep time not only different -which makes sense since int
> is translated to int16 apparently, with its overhead-, but independent
> on c (the input parameter ! ).


Do you mean if you change (A) but not (B) or vice-versa?

I'd check the assembler code to see what's happening to the upper byte of the int values.  If it's being left unchanged, all sorts of interesting things can happen, particularly if you call sleep-a-while with a value greater than 127.

Bob
--
Bob Jacobsen, LBNL Physics Division
####@####.#### +1-510-486-7355 AIM, Skype JacobsenRG






Previous by date: 12 Aug 2013 21:56:10 -0000 Re: PIC18F47J53, Luis de Arquer
Next by date: 12 Aug 2013 21:56:10 -0000 Re: PIC18F47J53, Luis de Arquer
Previous in thread: 12 Aug 2013 21:56:10 -0000 Re: PIC18F47J53, Luis de Arquer
Next in thread: 12 Aug 2013 21:56:10 -0000 Re: PIC18F47J53, Luis de Arquer


Powered by ezmlm-browse 0.20.