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

Blank FPrintF Changes Configuration?

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



Joined: 05 Jul 2010
Posts: 129

View user's profile Send private message

Blank FPrintF Changes Configuration?
PostPosted: Tue Aug 09, 2011 3:47 pm     Reply with quote

Hi,

I'm writing a program for an 18f4520 using compiler version 4.087 and after commenting our various fprintf() (I have 2 s/w implemented uarts) that I used for debugging I noticed my program wasn't working.

Going through the program I've managed to narrow the problem down to an fprintf statement.

With the following statement:

Code:
      fprintf(TC,"");


the code works - despite it not actually printing anything. With it commented out the program hangs.

Looking through the listings, a side by side comparison reveals the following differences when the uart is getting configured:

Commented Out:

Code:
.................... // -------------------------------------------------------------------------- //
.................... #use RS232 (stream = TC, baud=9600, xmit=PIN_C6, rcv=PIN_C7, FORCE_SW, ERRORS)
0112:  BSF    F94.7
0114:  BTFSC  F82.7
0116:  BRA    0114
0118:  MOVLW  08
011A:  MOVWF  00
011C:  CLRF   xCA
011E:  BSF    00.7
0120:  BRA    013E
0122:  BCF    00.7
0124:  BRA    013E
0126:  BCF    FD8.0
0128:  BTFSC  F82.7
012A:  BSF    FD8.0
012C:  RRCF   xCA,F
012E:  BSF    00.6
0130:  BRA    013E
0132:  BCF    00.6
0134:  DECFSZ 00,F
0136:  BRA    0126
0138:  MOVFF  CA,01
013C:  BRA    0168
013E:  MOVLW  01
0140:  MOVWF  FE9
0142:  MOVLW  00
0144:  BTFSC  00.7
0146:  MOVLW  55
0148:  MOVWF  01
014A:  DECFSZ 01,F
014C:  BRA    014A
014E:  DECFSZ FE9,F
0150:  BRA    0142
0152:  MOVLW  0D
0154:  BTFSC  00.7
0156:  MOVLW  03
0158:  MOVWF  01
015A:  DECFSZ 01,F
015C:  BRA    015A
015E:  BTFSC  00.7
0160:  BRA    0122
0162:  BTFSC  00.6
0164:  BRA    0132
0166:  BRA    0126
0168:  GOTO   019A (RETURN)
....................
.................... #use rs232(stream=TMS,baud=15625, xmit=PIN_C5, rcv=PIN_B0, INVERT, ERRORS)
*
01FA:  BCF    F94.5
01FC:  BSF    F8B.5
01FE:  MOVLW  08
0200:  MOVWF  01
0202:  BRA    0204
0204:  NOP   
0206:  BSF    01.7
0208:  BRA    0226
020A:  BCF    01.7
020C:  RRCF   xCF,F
020E:  BTFSC  FD8.0
0210:  BCF    F8B.5
0212:  BTFSS  FD8.0
0214:  BSF    F8B.5
0216:  BSF    01.6
0218:  BRA    0226
021A:  BCF    01.6
021C:  DECFSZ 01,F
021E:  BRA    020C
0220:  BRA    0222
0222:  NOP   
0224:  BCF    F8B.5
0226:  MOVLW  A4
0228:  MOVWF  FE9
022A:  DECFSZ FE9,F
022C:  BRA    022A
022E:  BRA    0230
0230:  BTFSC  01.7
0232:  BRA    020A
0234:  BTFSC  01.6
0236:  BRA    021A
0238:  RETLW  00
*
0332:  BSF    F93.0
0334:  BTFSS  F81.0
0336:  BRA    0334
0338:  MOVLW  08
033A:  MOVWF  00
033C:  CLRF   xCF
033E:  BSF    00.7
0340:  BRA    035E
0342:  BCF    00.7
0344:  BRA    035E
0346:  BCF    FD8.0
0348:  BTFSS  F81.0
034A:  BSF    FD8.0
034C:  RRCF   xCF,F
034E:  BSF    00.6
0350:  BRA    035E
0352:  BCF    00.6
0354:  DECFSZ 00,F
0356:  BRA    0346
0358:  MOVFF  CF,01
035C:  BRA    0376
035E:  MOVLW  A4
0360:  BTFSC  00.7
0362:  MOVLW  2C
0364:  MOVWF  01
0366:  DECFSZ 01,F
0368:  BRA    0366
036A:  NOP   
036C:  BTFSC  00.7
036E:  BRA    0342
0370:  BTFSC  00.6
0372:  BRA    0352
0374:  BRA    0346
0376:  GOTO   03A6 (RETURN)
.................... 


Without it commented out:
Code:

.................... // -------------------------------------------------------------------------- //
.................... #use RS232 (stream = TC, baud=9600, xmit=PIN_C6, rcv=PIN_C7, FORCE_SW, ERRORS)
0112:  BSF    F94.7
0114:  BTFSC  F82.7
0116:  BRA    0114
0118:  MOVLW  08
011A:  MOVWF  00
011C:  CLRF   xCA
011E:  BSF    00.7
0120:  BRA    013E
0122:  BCF    00.7
0124:  BRA    013E
0126:  BCF    FD8.0
0128:  BTFSC  F82.7
012A:  BSF    FD8.0
012C:  RRCF   xCA,F
012E:  BSF    00.6
0130:  BRA    013E
0132:  BCF    00.6
0134:  DECFSZ 00,F
0136:  BRA    0126
0138:  MOVFF  CA,01
013C:  BRA    0168
013E:  MOVLW  01
0140:  MOVWF  FE9
0142:  MOVLW  00
0144:  BTFSC  00.7
0146:  MOVLW  55
0148:  MOVWF  01
014A:  DECFSZ 01,F
014C:  BRA    014A
014E:  DECFSZ FE9,F
0150:  BRA    0142
0152:  MOVLW  0D
0154:  BTFSC  00.7
0156:  MOVLW  03
0158:  MOVWF  01
015A:  DECFSZ 01,F
015C:  BRA    015A
015E:  BTFSC  00.7
0160:  BRA    0122
0162:  BTFSC  00.6
0164:  BRA    0132
0166:  BRA    0126
0168:  GOTO   019A (RETURN)
*
01FA:  BCF    F94.6
01FC:  BCF    F8B.6
01FE:  MOVLW  08
0200:  MOVWF  01
0202:  BRA    0204
0204:  NOP   
0206:  BSF    01.7
0208:  BRA    0226
020A:  BCF    01.7
020C:  RRCF   xCF,F
020E:  BTFSC  FD8.0
0210:  BSF    F8B.6
0212:  BTFSS  FD8.0
0214:  BCF    F8B.6
0216:  BSF    01.6
0218:  BRA    0226
021A:  BCF    01.6
021C:  DECFSZ 01,F
021E:  BRA    020C
0220:  BRA    0222
0222:  NOP   
0224:  BSF    F8B.6
0226:  MOVLW  01
0228:  MOVWF  00
022A:  CLRF   FE9
022C:  DECFSZ FE9,F
022E:  BRA    022C
0230:  DECFSZ 00,F
0232:  BRA    022A
0234:  MOVLW  0E
0236:  MOVWF  FE9
0238:  DECFSZ FE9,F
023A:  BRA    0238
023C:  NOP   
023E:  BTFSC  01.7
0240:  BRA    020A
0242:  BTFSC  01.6
0244:  BRA    021A
0246:  RETLW  00
.................... 
.................... #use rs232(stream=TMS,baud=15625, xmit=PIN_C5, rcv=PIN_B0, INVERT, ERRORS)
*
0340:  BSF    F93.0
0342:  BTFSS  F81.0
0344:  BRA    0342
0346:  MOVLW  08
0348:  MOVWF  00
034A:  CLRF   xCF
034C:  BSF    00.7
034E:  BRA    036C
0350:  BCF    00.7
0352:  BRA    036C
0354:  BCF    FD8.0
0356:  BTFSS  F81.0
0358:  BSF    FD8.0
035A:  RRCF   xCF,F
035C:  BSF    00.6
035E:  BRA    036C
0360:  BCF    00.6
0362:  DECFSZ 00,F
0364:  BRA    0354
0366:  MOVFF  CF,01
036A:  BRA    0384
036C:  MOVLW  A4
036E:  BTFSC  00.7
0370:  MOVLW  2C
0372:  MOVWF  01
0374:  DECFSZ 01,F
0376:  BRA    0374
0378:  NOP   
037A:  BTFSC  00.7
037C:  BRA    0350
037E:  BTFSC  00.6
0380:  BRA    0360
0382:  BRA    0354
0384:  GOTO   03B4 (RETURN)


I can get round this problem by just using a blank fprintf but I'd like to know whether it's a compiler fault or something else I'm not aware of.

Cheers,
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Aug 09, 2011 4:39 pm     Reply with quote

you are not showing the code actually generated by your problem fprintf
are you ??

i assume it all works with fprintf(TC,"\r\n");

so what is the programmatic purpose of printing a null without printing
an actual asciiz ???
Geps



Joined: 05 Jul 2010
Posts: 129

View user's profile Send private message

PostPosted: Wed Aug 10, 2011 4:24 am     Reply with quote

No, I looked through the code and quoted those from the top of the file. When the line is commented out the compiler does skip through it and there is no assembly listed.

I can test that code in a couple of hours and let you know.


At the moment it's to stop it hanging - originally the program worked when there was text in there to print, I commented it out and it hung so I kept removing letters and found out that even though nothing gets printed it gets around this hanging problem.
jeremiah



Joined: 20 Jul 2010
Posts: 1346

View user's profile Send private message

PostPosted: Wed Aug 10, 2011 9:00 am     Reply with quote

Perhaps you have a non null terminated string somewhere?

Mind you, this is just a guess since you aren't providing a small program that shows the problem.

Could you post a small completely compilable program that duplicates the problem? It would help those here with debugging the issue.
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