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

Problem with bit_set() function on CCS 3.185

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







Problem with bit_set() function on CCS 3.185
PostPosted: Wed Feb 18, 2004 6:50 am     Reply with quote

Updating CCS compiler from 3.184 to 3.185, one of my software didn’t work anymore. I finally tracked down the problem to the “bit_set()” function that seemed to basically erased the whole int8 variable instead of setting the bit.

I changed the line :
bit_set(trame[j],i+3);

and replaced it with :
trame[j]|=0x01<<(i+3);

and now everything’s all right butI didn’t have that problem with 3.184.

Anybody else had similar experience ?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Feb 18, 2004 2:55 pm     Reply with quote

Quote:
Updating CCS compiler from 3.184 to 3.185, one of my software didn’t work anymore. I finally tracked down the problem to the “bit_set()” function that seemed to basically erased the whole int8 variable instead of setting the bit.


I think there is a problem. I analyzed the code produced by PCM 3.185
with an 16F877, and it looks like the compiler is leaving off two lines
of ASM code at the end. It calculates the correct bitmask, and combines
it with the value read from the array, but it does not put the result back
into the array.

Since you found the bug, do you want to email CCS tech support
about this ?

Code:

main()
{
char trame[10];
char j;
char i;
j = 0;
i = 4;

SYMBOLS
main.trame     00000021
main.j         0000002B
main.i         0000002C

0000    .................... bit_set(trame[j], i+3);   
000E 3021       MOVLW  21      // Get address of trame array       
000F 072B       ADDWF  2B,W    // Add j to it     
0010 0084       MOVWF  04      // Put the result in the FSR
0011 0800       MOVF   00,W    // Read the value at trame[0]
0012 00AD       MOVWF  2D      // Save it in 2D

0013 3003       MOVLW  03           
0014 072C       ADDWF  2C,W    // Get bit number (i+3) in W
0015 00AE       MOVWF  2E      // Save it in 2E

0016 3001       MOVLW  01      // Init the bitmask to 0x01
0017 00F7       MOVWF  77      // Save it in 77

0018 082E       MOVF   2E,W    // Get the bit number (i+3)
0019 00F8       MOVWF  78      // Put it in a counter variable

001A 1903       BTFSC  03.2    // Is the bit number = 0 ?
001B 2820       GOTO   020     // Jump if so -- bitmask is already done.
001C 1003       BCF    03.0    // Clear the carry flag
001D 0DF7       RLF    77,F    // Rotate the bitmask left by 1 bit
001E 0BF8       DECFSZ 78,F    // Continue until bitmask is done
001F 281C       GOTO   01C
0020 0877       MOVF   77,W    // Put bitmask into W
0021 04AD       IORWF  2D,F    // OR the bitmask with value read at trame[0]

// That's the end of the routine.  But there's a bug.
// It doesn't move the temp value in 2D back into
// the actual trame[0] ram location.

// I think it needs two more lines.

#asm
     movf  0x2D,w                // Put the finished byte into W
     movwf 0                     // Put W into trame[0] (by using FSR)
#endasm
schmobol
Guest







Problem with bit_set() function on CCS 3.185
PostPosted: Thu Feb 19, 2004 3:55 am     Reply with quote

Yes , that's done. I sent a message to CCS to mention that problem. We can expect to have it solved for the next release!

Thank you for your support
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sun Feb 22, 2004 8:44 am     Reply with quote

Hi folks,

Usually I dont download the last version to use it until it´s well mature, stable and bug free.

My suggestion:
for those who download and use the last version and found a bug not present in previous releases,
CCS would find a way to compensate for this, may be extending the expiration date to update or equivalent.
At least they do what CCS must had made it before, with extra money. A two-way favour.


Humberto
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