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

Strange and Big Problem!

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



Joined: 18 Oct 2003
Posts: 145

View user's profile Send private message

Strange and Big Problem!
PostPosted: Fri Aug 01, 2014 2:59 pm     Reply with quote

Hi,

I have a big problem, I have a firmware and when I add a new function the USE RS232 (soft) not work. I compare the two USE RS232 (ok and bad) and I see some differences but I not understand why?????

I need that you help me with this problem, I have two days working in solve this and I cannot, my customer want kill me!!! I think that the problem is when send bytes...

Any IDEA???

Thanks!!!

I use the last version with a 24HJ256GP206A

Code:
CCS PCD C Compiler, Version 5.026, xxxxx    01-ago-14 17:43

               ROM used:   66324 bytes (38%)
                           Largest free fragment is 61128
               RAM used:   5246 (32%) at main() level
                           9035 (55%) worst case
               Stack used: 136 locations (96 in main + 40 for interrupts)
               Stack size: 512

This is the .lst of USE when work
Code:

..... #use rs232( BAUD= SC_BAUD_RATE, PARITY = E, XMIT = SC_PIN_IO, RCV = SC_PIN_IO, BITS = 8, STOP = SC_STOP_BIT, STREAM = SC_SERIAL, DISABLE_INTS, ERRORS ) 
*
03272 AF62D4         BTSC.B  2D4.3          : Skip if PORTD.RD3 = 0
03274 37FFFE         BRA     3272           : GoTo 3272
03276 200083         MOV     #8,W3          : W3 = 8
03278 EB0100         CLR     W2             : W2 = 0
0327A F80042         PUSH    42             : PUSH SR to TOS
0327C A9E081         BCLR.B  81.7           : INTCON1.NSTDIS = 0
0327E B3CE00         MOV.B   #E0,W0L        : W0L = E0
03280 B7E042         MOV.B   W0L,42         : SRL = W0L
03282 A8E081         BSET.B  81.7           : INTCON1.NSTDIS = 1
03284 0903DE         REPEAT  #3DE           : Repeat next instruction (3DE + 1) times
03286 000000         NOP                    : No Operation
03288 090B98         REPEAT  #B98           : Repeat next instruction (B98 + 1) times
0328A 000000         NOP                    : No Operation
0328C A90042         BCLR.B  42.0           : SR.C = 0
0328E AF62D4         BTSC.B  2D4.3          : Skip if PORTD.RD3 = 0
03290 A80042         BSET.B  42.0           : SR.C = 1
03292 D3C102         RRC.B   W2L,W2L        : W2L = rotate right through Carry W2L
03294 E90183         DEC     W3,W3          : W3 = W3 - 1
03296 3AFFF8         BRA     NZ,3288        : if W3!=0 GoTo 3288
03298 090B9F         REPEAT  #B9F           : Repeat next instruction (B9F + 1) times
0329A 000000         NOP                    : No Operation
0329C 090B9F         REPEAT  #B9F           : Repeat next instruction (B9F + 1) times
0329E 000000         NOP                    : No Operation
032A0 780002         MOV     W2,W0          : W0 = W2
032A2 A9E081         BCLR.B  81.7           : INTCON1.NSTDIS = 0
032A4 F90042         POP     42             : POP TOS to SR
032A6 A8E081         BSET.B  81.7           : INTCON1.NSTDIS = 1
032A8 060000         RETURN                 : Return
*
033EE 781F85         MOV     W5,[W15++]     : Push W5 to TOS
033F0 BFC042         MOV.B   42,W0L         : W0L = SR
033F2 B7E00A         MOV.B   W0L,A          : W5L = W0L
033F4 A9E081         BCLR.B  81.7           : INTCON1.NSTDIS = 0
033F6 200E04         MOV     #E0,W4         : W4 = E0
033F8 880214         MOV     W4,42          : SR = W4
033FA A8E081         BSET.B  81.7           : INTCON1.NSTDIS = 1
033FC EB0200         CLR     W4             : W4 = 0
033FE A962D6         BCLR.B  2D6.3          : LATD.LATD3 = 0
03400 200083         MOV     #8,W3          : W3 = 8
03402 090B9C         REPEAT  #B9C           : Repeat next instruction (B9C + 1) times
03404 000000         NOP                    : No Operation
03406 BFDE6C         MOV.B   1E6C,W0L       : W0L = [1E6C]
03408 680204         XOR     W0,W4,W4       : W4 = W0 ^ W4
0340A D7FE6C         RRC.B   1E6C           : [1E6C] = rotate right through Carry [1E6C]
0340C AF0042         BTSC.B  42.0           : Skip if SR.C = 0
0340E A862D6         BSET.B  2D6.3          : LATD.LATD3 = 1
03410 AE0042         BTSS.B  42.0           : Skip if SR.C = 1
03412 A962D6         BCLR.B  2D6.3          : LATD.LATD3 = 0
03414 090B95         REPEAT  #B95           : Repeat next instruction (B95 + 1) times
03416 000000         NOP                    : No Operation
03418 E90183         DEC     W3,W3          : W3 = W3 - 1
0341A 3AFFF5         BRA     NZ,3406        : if W3!=0 GoTo 3406
0341C A70004         BTSC    W4.0           : Skip if W4.bit4 = 0
0341E A862D6         BSET.B  2D6.3          : LATD.LATD3 = 1
03420 A60004         BTSS    W4.0           : Skip if W4.bit = 1
03422 A962D6         BCLR.B  2D6.3          : LATD.LATD3 = 0
03424 090B9F         REPEAT  #B9F           : Repeat next instruction (B9F + 1) times
03426 000000         NOP                    : No Operation
03428 A862D6         BSET.B  2D6.3          : LATD.LATD3 = 1
0342A 200013         MOV     #1,W3          : W3 = 1
0342C 090B9C         REPEAT  #B9C           : Repeat next instruction (B9C + 1) times
0342E 000000         NOP                    : No Operation
03430 E90183         DEC     W3,W3          : W3 = W3 - 1
03432 3AFFFC         BRA     NZ,342C        : if W3!=0 GoTo 342C
03434 A9E081         BCLR.B  81.7           : INTCON1.NSTDIS = 0
03436 F80042         PUSH    42             : PUSH SR to TOS
03438 9FFFE5         MOV.B   W5L,[W15-#2]   : [W15+-2] = W5L
0343A F90042         POP     42             : POP TOS to SR
0343C A8E081         BSET.B  81.7           : INTCON1.NSTDIS = 1
0343E 7802CF         MOV     [--W15],W5     : POP TOS to [--W15]
03440 060000         RETURN                 : Return


This is the .lst of USE when NOT work!!!!
Code:

..... #use rs232( BAUD= SC_BAUD_RATE, PARITY = E, XMIT = SC_PIN_IO, RCV = SC_PIN_IO, BITS = 8, STOP = SC_STOP_BIT, STREAM = SC_SERIAL, DISABLE_INTS, ERRORS ) 
*
03DF6 AF62D4         BTSC.B  2D4.3          : Skip if PORTD.RD3 = 0
03DF8 37FFFE         BRA     3DF6           : GoTo 3DF6
03DFA 200083         MOV     #8,W3          : W3 = 8
03DFC EB0100         CLR     W2             : W2 = 0
03DFE F80042         PUSH    42             : PUSH SR to TOS
03E00 A9E081         BCLR.B  81.7           : INTCON1.NSTDIS = 0
03E02 B3CE00         MOV.B   #E0,W0L        : W0L = E0
03E04 B7E042         MOV.B   W0L,42         : SRL = W0L
03E06 A8E081         BSET.B  81.7           : INTCON1.NSTDIS = 1
03E08 0903DE         REPEAT  #3DE           : Repeat next instruction (3DE + 1) times
03E0A 000000         NOP                    : No Operation
03E0C 090B98         REPEAT  #B98           : Repeat next instruction (B98 + 1) times
03E0E 000000         NOP                    : No Operation
03E10 A90042         BCLR.B  42.0           : SR.C = 0
03E12 AF62D4         BTSC.B  2D4.3          : Skip if PORTD.RD3 = 0
03E14 A80042         BSET.B  42.0           : SR.C = 1
03E16 D3C102         RRC.B   W2L,W2L        : W2L = rotate right through Carry W2L
03E18 E90183         DEC     W3,W3          : W3 = W3 - 1
03E1A 3AFFF8         BRA     NZ,3E0C        : if W3!=0 GoTo 3E0C
03E1C 090B9F         REPEAT  #B9F           : Repeat next instruction (B9F + 1) times
03E1E 000000         NOP                    : No Operation
03E20 090B9F         REPEAT  #B9F           : Repeat next instruction (B9F + 1) times
03E22 000000         NOP                    : No Operation
03E24 780002         MOV     W2,W0          : W0 = W2
03E26 A9E081         BCLR.B  81.7           : INTCON1.NSTDIS = 0
03E28 F90042         POP     42             : POP TOS to SR
03E2A A8E081         BSET.B  81.7           : INTCON1.NSTDIS = 1
03E2C 060000         RETURN                 : Return
*
03FB8 781F85         MOV     W5,[W15++]     : Push W5 to TOS
03FBA BFC042         MOV.B   42,W0L         : W0L = SR
03FBC B7E00A         MOV.B   W0L,A          : W5L = W0L
03FBE A9E081         BCLR.B  81.7           : INTCON1.NSTDIS = 0
03FC0 200E04         MOV     #E0,W4         : W4 = E0
03FC2 880214         MOV     W4,42          : SR = W4
03FC4 A8E081         BSET.B  81.7           : INTCON1.NSTDIS = 1
03FC6 EB0200         CLR     W4             : W4 = 0
03FC8 A962D6         BCLR.B  2D6.3          : LATD.LATD3 = 0
03FCA 200083         MOV     #8,W3          : W3 = 8
03FCC 090B9C         REPEAT  #B9C           : Repeat next instruction (B9C + 1) times
03FCE 000000         NOP                    : No Operation
03FD0 811294         MOV     2252,W4        : W4 = [2252]
03FD2 BFC008         MOV.B   8,W0L          : W0L = W4
03FD4 891294         MOV     W4,2252        : [2252] = W4
03FD6 680204         XOR     W0,W4,W4       : W4 = W0 ^ W4
03FD8 811294         MOV     2252,W4        : W4 = [2252]
03FDA D7E008         RRC.B   8              : W4L = rotate right through Carry W4L
03FDC 891294         MOV     W4,2252        : [2252] = W4
03FDE AF0042         BTSC.B  42.0           : Skip if SR.C = 0
03FE0 A862D6         BSET.B  2D6.3          : LATD.LATD3 = 1
03FE2 AE0042         BTSS.B  42.0           : Skip if SR.C = 1
03FE4 A962D6         BCLR.B  2D6.3          : LATD.LATD3 = 0
03FE6 090B95         REPEAT  #B95           : Repeat next instruction (B95 + 1) times
03FE8 000000         NOP                    : No Operation
03FEA E90183         DEC     W3,W3          : W3 = W3 - 1
03FEC 3AFFF1         BRA     NZ,3FD0        : if W3!=0 GoTo 3FD0
03FEE A70004         BTSC    W4.0           : Skip if W4.bit4 = 0
03FF0 A862D6         BSET.B  2D6.3          : LATD.LATD3 = 1
03FF2 A60004         BTSS    W4.0           : Skip if W4.bit = 1
03FF4 A962D6         BCLR.B  2D6.3          : LATD.LATD3 = 0
03FF6 090B9F         REPEAT  #B9F           : Repeat next instruction (B9F + 1) times
03FF8 000000         NOP                    : No Operation
03FFA A862D6         BSET.B  2D6.3          : LATD.LATD3 = 1
03FFC 200013         MOV     #1,W3          : W3 = 1
03FFE 090B9C         REPEAT  #B9C           : Repeat next instruction (B9C + 1) times
04000 000000         NOP                    : No Operation
04002 E90183         DEC     W3,W3          : W3 = W3 - 1
04004 3AFFFC         BRA     NZ,3FFE        : if W3!=0 GoTo 3FFE
04006 A9E081         BCLR.B  81.7           : INTCON1.NSTDIS = 0
04008 F80042         PUSH    42             : PUSH SR to TOS
0400A 9FFFE5         MOV.B   W5L,[W15-#2]   : [W15+-2] = W5L
0400C F90042         POP     42             : POP TOS to SR
0400E A8E081         BSET.B  81.7           : INTCON1.NSTDIS = 1
04010 7802CF         MOV     [--W15],W5     : POP TOS to [--W15]
04012 060000         RETURN                 : Return
temtronic



Joined: 01 Jul 2010
Posts: 9162
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Aug 01, 2014 6:07 pm     Reply with quote

I don't use that PIC but...

1) both #use rs232(...) appear to have the same options,so they should be the same. You don't point out the differences which would up my tired eyes.

2)they compile at different memory spaces.

that leads me to believe you've modified other code that we don't know about.

You should post a small compilable program that shows us the problem.
Without seeing the real program I can't understand where the problem is.

We need some more information.

hth
jay
Ttelmah



Joined: 11 Mar 2010
Posts: 19328

View user's profile Send private message

PostPosted: Sat Aug 02, 2014 12:54 am     Reply with quote

Key thing is 'what happens'. Are the bytes being sent, but corrupted?. Or is the processor crashing?.
If so, then you are almost certainly getting a trap interrupt.
Only 'user' interrupts are disabled.
Normally a trap would cause a reset, but if you have enabled you own trap functions 'anything is possible'. How big is your stack?. Adding the extra function may have simply taken you over the stack size allocated.
cfernandez



Joined: 18 Oct 2003
Posts: 145

View user's profile Send private message

PostPosted: Sat Aug 02, 2014 12:29 pm     Reply with quote

I can see that the problem is when I define global large array > 2Kb. I don't know why happen this, I have too much ram. I send a email to CCS.

Regards,
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