I finally got back to my project, and have some newbie questions. I am using HiTech C, and was trying to locate the proper functions to use for my PIC18f4685. To format the int values into ASCII, can I use UTOA? And then use PUTS? I am new to using C with microcontrollers.
so would this code work? puts(#1P1500S333/r);
or could I use a printf? Do I need to use /r/n or ?? I see both mentioned.
Ah now I see, the sprintf() makes the string. Cool.
Is the PutString() function in the compiler? Or is that a function that you wrote yourself. I still have not looked through the documentation on how to send serial data. Is it as simple as writing the data to a register and then waiting for a flag to tell you it is ready for more characters?
/* Wait while buffer is full as interrupt changes Front pointer. */
ndx = (TxTailPtr + 1) & TX_BUFF_MASK;
/* One char is removed by interrupt routine while loop exits. */
while(ndx == TxHeadPtr); /* BLOCKS if no room in BUFFER!! */
PEIE = 0; /* don't let interrupt modify what we look at */
if(TXIE == 0) /* enable TX interrupt on first char to send */
{
TXREG = chr;
TXIE = 1; /* ENABLE interrupt to handle sending chars */
}
else
{
TxBuff[TxTailPtr++] = chr; /* char into XMIT buffer */
TxTailPtr &= TX_BUFF_MASK; /* wrap the buffer */
}
PEIE = 1; /* Let interrupt finish */
}
[/code]
My receive routine uses a buffer also, and I can get either a char or a full string.
Writing to the TXREG sends a character, check TXIF first to see if transmit buffer is empty.
There are demos for char send/receive on the Microchip website, and shipped with the compilers.