slosjo,
Here's a little example code for you. I try to hide the lowest level code, so the actual transmit stuff could be put into one function. In my app., I have to be able to switch back and forth between SCI1 and SCI2, hence the Enable and Disable functions, but you probably will only need to enable the SCI once using the CW gui (it ends up in the MCUinit function if you enable C initialization in the New Project Wizard).
It might also help to look at how you can use the #defines in the header file for your processor. These #defines let you refer directly to registers and bits in those registers without having to create them yourself. It takes a little study to figure it out, but is really a time-saver once you do. The #defines are usually named the same as they are in the data sheet, which makes it pretty easy.
//-----------------------------------------------------------------------
// SCI1_Enable() - function to enable SCI channel 1
//
// arguments: none
// returns: nothing
//-----------------------------------------------------------------------
void SCI1_Enable( void )
{
SCI1C2 = 0x2C; // enable Rx irq's, enable Tx, enable Rx
}
//-----------------------------------------------------------------------
// SCI1_Disable() - function to disable SCI channel 1
//
// arguments: none
// returns: nothing
//-----------------------------------------------------------------------
void SCI1_Disable(void)
{
SCI1C2 = 0; // disable everything
}
//-----------------------------------------------------------------------
// SCI1_SendChar() - function to write a char to SCI channel 1
//
// arguments: value - char to send
// returns: nothing
//-----------------------------------------------------------------------
void SCI1_SendChar( char value )
{
while( SCI1S1_TDRE == 0 ); // wait for xmit register to be MT
SCI1D = value;
}
/*--------------- 3/2/07 -----------------------------
* Function to output a NULL terminated C string to SCI1.
-------------------------------------------------------
*/
void TxPutStr(char *st)
{
while(*st) SCI1_SendChar(*st++);
}
Hope this helps,
bill