Jump to content

Recommended Posts


I am trying to print a rom string to the serial port, the strings are defined thus:

rom char *test_txt = "\n\rMatrix Controller Test mode\n\r";
rom char *txt1 = "Connect an 80R 10W resistor across pins 11 and 19\n\r";
rom char *txt2 = "Press Enter when ready\n\r";

i use the following call:

puts (test_txt);

where puts() is:

void puts(rom char* c)
char cc;
char i;
for( i = 0; cc = c[ i ]; i++ )
putc( cc );

void putc(char c)
txsta.TXEN = 1;
txreg = c;
while (txsta.TRMT == 0) clear_wdt();

But all of the strings are printed one after the other and then looping to the start again until the 255 char limit is reached, it appears that the routine isn't detecting the end of string \0 - i also tried putting a \0 at the end os each string, I have checked the prog mem and each rom strings ends in a retlw 0

Can anyone tell me what I'm doing wrong, i'm using a pic16F887 processor, the above code works fine on a pic 18F25 series chip


rob carter


Công ty Dịch vụ chăm sóc sau sinh bệnh viện Hùng Vương chuyên nghiệp giúp việc theo giờ chất lượng giúp việc theo giờ tại gò vấp hiệu quả

Edited by kittysoman
Link to post
Share on other sites

Delayed reply, even thus maybe helpfull for others

As Reynard said, why not...

#include <system.h>

// zero at the end, to end of string detection
rom char *test_txt = "\n\rMatrix Controller Test mode\n\r\0";

void puts( rom char* c )
    for( unsigned char i=0;;i++ )
        while( !txsta.TRMT ) clear_wdt();
        if( c[i] != 0 ) { txreg = c[i]; } else break;

void main( void )
    puts( test_txt );


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...