string as parameter

This is a discussion on string as parameter within the C++ Programming forums, part of the General Programming Boards category; Hello Hello I work with a PIC18F46K20 and now I want with a Function send text with RS232 to HyperTerminal. ...

  1. #1
    Registered User
    Join Date
    Sep 2009
    Posts
    4

    string as parameter

    Hello

    Hello

    I work with a PIC18F46K20
    and now I want with a Function send text with RS232 to HyperTerminal.
    Now I have the following code created.
    Code:
    // above the main 
    void UART_DEBUG_TEXT(const char szText[])
     
    //in the while
    UART_DEBUG_TEXT(Hello);
     
    //below the main
    void UART_DEBUG_TEXT(const char szText[])		
    {
    	unsigned char i = 0; 										
    	while(szText[i] != '\0')
    	{
    		if(UARTIntPutChar(szText[i]))	
    			i++;											
       }
    }

    Now the problem that I see strange characters in hyper terminal. This example:
    ;f``zb..)HA `:S}N

    maybe someone knows what the problem is?

  2. #2
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    Location
    RING 0
    Posts
    507
    Are you sending and receiving at the same baud rate?
    For that matter is the protocol you are sending being expected by the receiving app? IE proper amount of stop bits etc...?

    Assuming szText points to some valid string ("You haven't provided in the code rather it does or not"), then there doesn't seem to be anything wrong with your function.
    Last edited by valaris; 09-17-2009 at 07:33 AM.

  3. #3
    Registered User
    Join Date
    Sep 2009
    Posts
    4
    hello

    thanks for you answer

    My bautrate is good :
    because if I do it this way without fuctie it goes well:
    Code:
    k = 0;
    while(k < 18)
    {
         if(UARTIntPutChar(cArray2[k]))
            k++;
         Delay10KTCYx(100000);
    }
    Wim

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Please check my C++
    By csonx_p in forum C++ Programming
    Replies: 263
    Last Post: 07-24-2008, 09:20 AM
  2. Custom String class gives problem with another prog.
    By I BLcK I in forum C++ Programming
    Replies: 1
    Last Post: 12-18-2006, 02:40 AM
  3. Something is wrong with this menu...
    By DarkViper in forum Windows Programming
    Replies: 2
    Last Post: 12-14-2002, 10:06 PM
  4. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 02:23 PM
  5. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 01:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21