Jump to content

Issue With Txbuffer Initialization?


Recommended Posts

After startup the first message the PIC should send is this: A Test:

Instead I get this:

x??????o??????w???i*?w??????w? Test:

 

This is with txBuffer[64]. If I change it to txBuffer[16] I get this:

??????? Test:

 

It is only the first message. The first message is sent on command sometime after the serial port is opened.

 

If I send a single char right after uart1Init() the problem does not occur. The garbage message is still sent but I clear the buffers when I open the serial port.

 

Any ideas?

 

Thanks,

Colin

Edited by zoom
Link to post
Share on other sites

It's your code responsibility to make sure txHead/txTail/rxHead/rxTail/rxCnt are initialised to zero at start. Sample code from SourceBoost installation declares them as static what makes compiler generate code that initialises them to zero. If you don't use static you need a statement like txHead= txTail = rxHead = rxTail = rxCnt = 0; somewhere in you initialisation code.

 

Regards,

Pavel

Link to post
Share on other sites
It's your code responsibility to make sure txHead/txTail/rxHead/rxTail/rxCnt are initialised to zero at start. Sample code from SourceBoost installation declares them as static what makes compiler generate code that initialises them to zero. If you don't use static you need a statement like txHead= txTail = rxHead = rxTail = rxCnt = 0; somewhere in you initialisation code.

 

Regards,

Pavel

Thanks Pavel.

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.

Guest
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.

Loading...
×
×
  • Create New...