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

PCD coding errors

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



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PCD coding errors
PostPosted: Mon Sep 29, 2008 11:54 am     Reply with quote

Hello,

I ported ex_modbus_slave.c to PIC24F and experienced a coding error, that causes failure of the respective operation (resulting in all zero output data in Coil and Input read). The erroneous behaviour can be easily seen in PCD assembly listing:
Code:
data = data & (0xFF>>(8-modbus_rx.data[3]));  //0 out values after quantity
02422:  MOV     #8,W4
02424:  MOV     8E8,W3  ; data
02426:  LSR     W3,#8,W3
02428:  SUB.B   W4L,W3L,W0L ; substract result to W0L
; here's the bug
0242A:  MOV     #FF,W0      ; mask also loaded to R0
0242C:  CLR.B   1
0242E:  LSR     W0,W0,W0
02430:  AND.B   950


Most likely, the error can be removed by rearranging the code. But iit's a serious problem, when any line of code must be suspected to be coded incorrect.

I experienced a similar problem one day before when porting some Microchip code (AN1095, Emulation of Data EEPROM in code memory). In this case, a wrong WREG address has been used at addr 018DA.

Code:
742:                   if(latch != (data & 0xFF))
 018D2  804800     mov.w 0x0900,0x0000  ; int16 data
 018D4  B20FF0     and.w #0xff,0x0000
 018D6  804864     mov.w 0x090c,0x0008  ; int8 latch
 018D8  EF6009     clr.b 0x0009
 018DA  E30004     cp.w 0x0004          ; must be cp.w 0x0008 !!
 018DC  320006     bra z, 0x0018ea


Both cases are related to int8 variables. The compiler version is V4.079.

Best regards,
Frank
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