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 support@ccsinfo.com

problem with shift_left function

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



Joined: 19 May 2006
Posts: 23
Location: Connecticut

View user's profile Send private message

problem with shift_left function
PostPosted: Fri Nov 20, 2009 4:25 pm     Reply with quote

I have been working with PCWH compiler version 4.100 for a couple of days now. I have been able to get my circuit to function, but in the process I have discovered that the functions shift_left and shift_right do not work. I have reported the issue to CCS technical support.

I used the following code as a work-around:

Instead of the built-in,
Code:

shift_left(&MyBuffer,2,input(PIN_A1));

I used
Code:

MyBuffer<<=1;
if(input(PIN_A1))
  MyBuffer += 1;
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 20, 2009 4:38 pm     Reply with quote

Post your PIC. Post a compilable test program.
Piccolo



Joined: 19 May 2006
Posts: 23
Location: Connecticut

View user's profile Send private message

PostPosted: Fri Nov 20, 2009 5:11 pm     Reply with quote

I'm using the PIC16F1937. I didn't post it because I guess it's not part-specific, but I could be wrong.

Code something like this:

To read 16 bits of data from PIN_A1 into a 16-bit:
Code:

int16 MyBuffer;
for(i=0;i<16;i++)
{
  ..wait for some sync. signal, like another IO line going high..
  MyBuffer<<=1;
  if(input(PIN_A1)
    MyBuffer +=1;
  ..wait for sync signal like IO line going low..
}

When I compiled my original code, which had been working just fine on previous versions, examination of the ASM file showed the shift_left function actually had "???" instead of a GOTO command. I'm sure it will be fixed. I only posted this in case someone else was having the same trouble and this may help. Enjoy the weekend.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Nov 20, 2009 6:09 pm     Reply with quote

I made a test program and compiled it with versions 4.099 and 4.100.
It produces the same code for each version. You said it worked with
version 4.099. If it's the same .LST code, how can it then fail in vs.
4.100 ?

There appear to be at least 3 bugs. There's apparently an illegal opcode,
and the RLF instruction operates on the wrong memory addresses for
'MyBuffer'.

These bugs don't exist for the 16F877. I would guess they are only
in the new 16F19xx series, which has a new architecture and a new
register map.

vs. 4.100
Code:

00576 ...... shift_left(&MyBuffer,2,input(PIN_A1)); 
001C 148C       00577 BSF    0C.1   // Set TRISA.1 = input

001D 0020       00578 MOVLB  00     // Bank 0
001E 188C       00579 BTFSC  0C.1   // Test PortA.1
001F 2822       00580 GOTO   022    // Jump if PortA.1 = 1

0020 1003       00581 BCF    03.0   // Clear LSB bit in MyBuffer
0021 2823       00582 GOTO   023

0022 1403       00583 BSF    03.0   // Set the LSB bit in MyBuffer
0023 0060       00584 ???           // Unknown opcode (Bug ?)

 // Rotate MyBuffer left 1 bit position
0024 0D81       00585 RLF    01,F  // Should be RLF 21,F (Bug ?) 
0025 0D82       00586 RLF    02,F  // Should be RLF 22,F (Bug ?)


vs. 4.099
Code:

00474 ..... shift_left(&MyBuffer,2,input(PIN_A1)); 
001C 148C       00475 BSF    0C.1
001D 0020       00476 MOVLB  00
001E 188C       00477 BTFSC  0C.1
001F 2822       00478 GOTO   022
0020 1003       00479 BCF    03.0
0021 2823       00480 GOTO   023
0022 1403       00481 BSF    03.0
0023 0060       00482 ???
0024 0D81       00483 RLF    01,F
0025 0D82       00484 RLF    02,F


Code:

SYMBOL TABLE
  LABEL                             VALUE

main.MyBuffer                     00000021

Test program:
Code:

#include <16F1937.h>
#fuses XT,NOWDT,BROWNOUT,PUT,NOLVP
#use delay(clock=4000000)

//======================================
void main(void)
{
int16 MyBuffer;
   
shift_left(&MyBuffer,2,input(PIN_A1));

while(1);
}
Piccolo



Joined: 19 May 2006
Posts: 23
Location: Connecticut

View user's profile Send private message

PostPosted: Mon Nov 23, 2009 10:52 am     Reply with quote

FYI: I received notice today from CCS Tech Support that the fix is in the next release.
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