コード例 #1
0
void LCD_byte (unsigned char x)
{
	// The accumulator in the C8051Fxxx is bit addressable!
	ACC=x; //Send high nible
	LCD_D7=ACC_7;
	LCD_D6=ACC_6;
	LCD_D5=ACC_5;
	LCD_D4=ACC_4;
	LCD_pulse();
	Timer3us(40);
	ACC=x; //Send low nible
	LCD_D7=ACC_3;
	LCD_D6=ACC_2;
	LCD_D5=ACC_1;
	LCD_D4=ACC_0;
	LCD_pulse();
}
コード例 #2
0
ファイル: LCD.c プロジェクト: apdahlen/uC_ana
/**
 * @brief Send a byte to the LCD using a 4-bit wide interface.
 *
 * @param C is the character to be sent to the LCD.
 *
 * @return void
 *
 * @note
 *
 * - When assigning a char to a single bit the MICROCHIP C18 compiler assigns
 *   the the character's LSB to the single bit.  This is convenient in this
 *   function as it allows the individual bits to be assigned using a series of
 *   shift left commands.
 *
 * - This function assumes other background function will use the data I/O.
 *   Consequently, it starts by configuring the data lines as outputs.
 *
 */
static void LCD_w_byte (char C) {

    LCD_D0_DIRECTION = OUTPUT;
    LCD_D1_DIRECTION = OUTPUT;
    LCD_D2_DIRECTION = OUTPUT;
    LCD_D3_DIRECTION = OUTPUT;

    LCD_D0_PIN = C >> 4;                		// send the upper nibble
    LCD_D1_PIN = C >> 5;
    LCD_D2_PIN = C >> 6;
    LCD_D3_PIN = C >> 7;

    LCD_pulse();

    LCD_D0_PIN = C & 0x01;                      // send the lower nibble
    LCD_D1_PIN = C >> 1;
    LCD_D2_PIN = C >> 2;
    LCD_D3_PIN = C >> 3;

    LCD_pulse();

//   LCD_D3_DIRECTION = INPUT;            		/**@todo WHY? */
//    delay_ISR_ticks(2);
}