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

Apparent problem with streams on the 18F452

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



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

Apparent problem with streams on the 18F452
PostPosted: Sun Aug 15, 2004 12:41 pm     Reply with quote

I just sent CCS the following message about a problem I have encountered with 18F452 streams:

In the 18F452 file I define two RS232 streams as CCT and EIS.

In the listing file at 0x0788 you will see where I print to the CCT stream. If you follow the code generated, the PRINTF does not output to the hardware UART at 0xFAD and 0xFAC but instead appears to call the EIS stream and tries to output to the software serial port.

I have tried this with Versions 3.191, 3.206 and 3.207 all with the same results.

If I remove the second stream everything works fine.

Code:

0784:  BCF    F96.0
0786:  BTG    F8D.0
....................                     printf(CCT_ACK_MSG,CCT);  // send ack 
0788:  MOVLW  40
078A:  MOVWF  x9B
078C:  CALL   02E2
....................                     delay_ms(5); 
0790:  MOVLW  05
0792:  MOVWF  x9A
0794:  CALL   05EA
....................                     printf(WD_MSG,CCT);  // send watchdog message 
0798:  CLRF   x9A
079A:  MOVF   x9A,W
079C:  CALL   00A2
07A0:  INCF   x9A,F
07A2:  MOVWF  00
07A4:  MOVFF  00,9B
07A8:  CALL   02E2
07AC:  MOVLW  05
07AE:  SUBWF  x9A,W
07B0:  BTFSS  FD8.2
07B2:  GOTO   079A
....................                     break; 
07B6:  GOTO   0832



USE RS232 Definitions

Code:


....................   #use RS232(STREAM=CCT, baud=9600,xmit=PIN_C6,rcv=PIN_C7,PARITY=N,BITS=8,RESTART_WDT,ERRORS) 
*
01F0:  CLRWDT
01F2:  BTFSS  F9E.5
01F4:  GOTO   01F0
01F8:  MOVF   FAB,W
01FA:  MOVWF  17
01FC:  MOVF   FAE,W
01FE:  MOVWF  01
0200:  BTFSS  17.1
0202:  GOTO   020A
0206:  BCF    FAB.4
0208:  BSF    FAB.4
020A:  NOP   
020C:  GOTO   0228 (RETURN)
....................   #use RS232(STREAM=EIS, baud=9600,xmit=PIN_C3,rcv=PIN_C0, PARITY=N,BITS=8,RESTART_WDT, ERRORS) 
*
02E2:  BCF    F94.3
02E4:  BCF    F8B.3
02E6:  MOVLW  08
02E8:  MOVWF  01
02EA:  NOP   
02EC:  NOP   
02EE:  NOP   
02F0:  BSF    01.7
02F2:  GOTO   0318
02F6:  BCF    01.7
02F8:  RRCF   x9B,F
02FA:  BTFSC  FD8.0
02FC:  BSF    F8B.3
02FE:  BTFSS  FD8.0
0300:  BCF    F8B.3
0302:  BSF    01.6
0304:  GOTO   0318
0308:  BCF    01.6
030A:  DECFSZ 01,F
030C:  GOTO   02F8
0310:  NOP   
0312:  NOP   
0314:  NOP   
0316:  BSF    F8B.3
0318:  MOVLW  01
031A:  MOVWF  00
031C:  CLRF   FE9
031E:  DECFSZ FE9,F
0320:  GOTO   031E
0324:  DECFSZ 00,F
0326:  GOTO   031C
032A:  MOVLW  38
032C:  MOVWF  FE9
032E:  DECFSZ FE9,F
0330:  GOTO   032E
0334:  CLRWDT
0336:  BTFSC  01.7
0338:  GOTO   02F6
033C:  BTFSC  01.6
033E:  GOTO   0308
0342:  RETLW  00
0344:  MOVLW  08
0346:  MOVWF  00
0348:  BSF    F94.0
034A:  CLRWDT
034C:  BTFSC  F82.0
034E:  GOTO   034A
0352:  CLRF   x9E
0354:  BSF    00.7
0356:  GOTO   037E
035A:  BCF    00.7
035C:  GOTO   037E
0360:  BCF    FD8.0
0362:  BTFSC  F82.0
0364:  BSF    FD8.0
0366:  RRCF   x9E,F
0368:  BSF    00.6
036A:  GOTO   037E
036E:  BCF    00.6
0370:  DECFSZ 00,F
0372:  GOTO   0360
0376:  MOVF   x9E,W
0378:  MOVWF  01
037A:  GOTO   03B6
037E:  MOVLW  01
0380:  MOVWF  FE9
0382:  MOVLW  00
0384:  BTFSC  00.7
0386:  MOVLW  55
0388:  MOVWF  01
038A:  DECFSZ 01,F
038C:  GOTO   038A
0390:  DECFSZ FE9,F
0392:  GOTO   0382
0396:  MOVLW  37
0398:  BTFSC  00.7
039A:  MOVLW  0F
039C:  MOVWF  01
039E:  DECFSZ 01,F
03A0:  GOTO   039E
03A4:  NOP   
03A6:  BTFSC  00.7
03A8:  GOTO   035A
03AC:  BTFSC  00.6
03AE:  GOTO   036E
03B2:  GOTO   0360
03B6:  GOTO   0428 (RETURN)
.................... // 


Is there something I am doing/seeing wrong here?

BTW, I tried this with #OPT 1 ,5 and 9. same result.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Aug 15, 2004 1:00 pm     Reply with quote

Can you post a small demo program that I can drop into MPLAB and test ?
LomasS
Guest







PostPosted: Sun Aug 15, 2004 1:56 pm     Reply with quote

CCS Documentation states that you need fprintf() not printf() to direct the output to streams. Do you really use printf() ?

Steve.
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

I seem to have missed that tidbit...
PostPosted: Sun Aug 15, 2004 2:08 pm     Reply with quote

Interesting, I seem to have missed that one!

Printf() has worked for me with multiple streams in the past but in a much simpler program so I must have lucked out and never realized the FPrintF() issue!

Strangely, when I cut the program that is having problems down to an example level (I still have two streams defined) printf still takes the Stream value and works as it should to either stream.

I will go back and try Fprinf(). I hope that works!

Thanks!
dyeatman



Joined: 06 Sep 2003
Posts: 1912
Location: Norman, OK

View user's profile Send private message

That does it...
PostPosted: Sun Aug 15, 2004 3:02 pm     Reply with quote

The FPrintf worked... Thanks Steve!

I went back and checked a program I wrote earlier where I specified the stream after the printf value (i.e printf(msg, stream)) and confirmed it worked for some crazy reason and the compiler didn't complain! Guess I just stumbled into a fluke of the code...

When the compiler didn't complain. it appears it may have had something to do with the default STDOUT... Oh well, mine is not to reason why, on to more bugs!
LomasS
Guest







PostPosted: Mon Aug 16, 2004 4:59 am     Reply with quote

It would appear that the real problem is that the compiler did not flag the printf with incorrect parameters, had it done so I'm sure you'd have found it.
Learning from mistakes is the best way, the advantage of this forum is that we can learn from the mistakes of others too!

Glad to be of help.
Steve.
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