0

I2C を使用して LCD2041 と通信しようとしています。PIC32MM キュリオシティ ボードを使用しています。MP lab code configurator で以下のコードを書いたのですが、I2c 通信のステータスが I2C2_MESSAGE_PENDING のままです。何を間違えたのか、何が欠けているのかについて助けが必要です。

#include <stdint.h>
#include <string.h>
#include <xc.h>
#include "mcc_generated_files/mcc.h"
//#include "lcd_i2c.h"

#define slave_Adress 0b01010000 

void ByteDelay(void){
    // Delay between bytes required by LCD2041 spec
    DELAY_microseconds(625);
}

void ReadDelay(void){
    // Delay between read commands required by LCD2041 spec
    DELAY_milliseconds(3);
}

void TransactionDelay(void){
    // Delay between transactions required by LCD2041 spec
    DELAY_microseconds(375);
}

int main(void)
{
   SYSTEM_Initialize();
   uint8_t data = 0xFE; // host to tell data are output via I2c   
   uint8_t lcd_clear_display =  0xA4; // command    to clear LCD
   TRISBbits.TRISB2 = 1; // set B2 (scl) as input 
    TRISBbits.TRISB3 = 1; // set B3 (SDA) as input 
    
   I2C2_Initialize() ;   
   I2C2_MESSAGE_STATUS status ; 
   I2C2_MasterWrite(data, 1 , slave_Adress, &status);
    ByteDelay();
    if ( status == I2C2_MESSAGE_PENDING) {led_3_SetHigh();} 
    return 1; 
}

LCD のデフォルトのスレーブ アドレスは 0x50 です。

4

1 に答える 1