Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] getting 0x00 at end of string sent via uart on pic18f97j60

Status
Not open for further replies.

dmsherazi

Newbie
Joined
Mar 25, 2015
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
36
hi , I am using TCP ip stack provided by microchip, I am using the pic net demo 2 board. When I send any string from the uart I receive 00 at strat of the string

Here is what i get when I send "New IP Address: " I would receive "New IP Address: [00]" on the terminal.

Here is the part where Uart is initialized.
Code:
// Configure USART
    TXSTA = 0x20;
    RCSTA = 0x90;
 // See if we can use the high baud rate setting
    #if ((GetPeripheralClock()+2*BAUD_RATE)/BAUD_RATE/4 - 1) <= 255
        SPBRG = (GetPeripheralClock()+2*BAUD_RATE)/BAUD_RATE/4 - 1;
        TXSTAbits.BRGH = 1;
    #else    // Use the low baud rate setting
        SPBRG = (GetPeripheralClock()+8*BAUD_RATE)/BAUD_RATE/16 - 1;
    #endif


    // Enable Interrupts
    RCONbits.IPEN = 1;        // Enable interrupt priorities
    INTCONbits.GIEH = 1;
    INTCONbits.GIEL = 1;
    INTCONbits.PEIE = 1; // enable peripheral interrupts.
    PIE1bits.RCIE   = 1; // enable USART receive interrupt
    IPR1bits.RCIP=0; // EUSART Receive Interrupt Priority 0 = Low priority


and this is the code to put the string on uart
Code:
void putrsUSART(const rom char *data)
	{
	  do
	  {  // Transmit a byte
	    while(BusyUSART());
	    putcUART(*data);
	  } while( *data++ );
	}

is there some thing that I am missing?
 

jsbhalla88

Member level 1
Joined
Mar 3, 2015
Messages
41
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
314
did you try to echo to check your code..???
you can try removing "const rom" from your function argument..
 

Aussie Susan

Advanced Member level 4
Joined
Jan 5, 2015
Messages
1,247
Helped
377
Reputation
754
Reaction score
375
Trophy points
83
Activity points
13,503
Move the loop test to the start of the loop.
The 'convention' is for C strings to be terminated by a NULL byte. While you are testing for that NULL value, you are doing that after you have sent it.
I would imagine that you are seeing the NULL byte being received by the PC and the terminal emulator program displaying that as "[00]" which could be its way of saying that it has received a byte that does not correspond to a displayable character and showing you the hex(??) value.
Susan
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top