FIGURE 4. Basic target LCD interface schematic.
Code Block 1
void dbyte2man(unsigned char inbyte,unsigned char
BitsToSend)
{
unsigned char i;
DB_Bit = 1;;;;;//mark 1
__delay_ms(HBitTime*2);
for(i=1;i<=BitsToSend;i++)
//sending LSB first
{
if(inbyte & 0x01)
//position 1 for rising
{
DB_Bit = 0;
__delay_us(HBitTime);
DB_Bit = 1;
__delay_us(HBitTime);
}
else
{
DB_Bit = 1;
//position 0 for falling
__delay_us(HBitTime);
DB_Bit = 0;
__delay_us(HBitTime);
}
inbyte = inbyte>>1;
}
DB_Bit = 1;;;;;;;;;;;;//mark 1
__delay_ms(HBitTime*2);
}
#define HBitTime 400
//half the bit time in microseconds
#define DB_Bit RC3
//out serial output bit
Embed this function in your code and call it anywhere
you want to pass the internal value of a byte to the
outside world. If you need to send more than eight bits,
just change the data-type in the function definition to int,
short long, long as needed, and adjust the BitsToSend
parameter.
A Quick and Simple Example
FIGURE 5. Saleae logic error region decoding.
I had a project that
needed a character LCD
and keypad interfaced to a
PIC6F877A controller. It’s
easiest to use a four-bit
LCD interface as it fits an
eight-bit port (seven total
lines) and a scanned 4x4
matrix keypad on another
eight-bit port. This worked
well on both the
development board
(d_board) as shown in
34 March 2018