MKE18F512 LPI2C not Work

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MKE18F512 LPI2C not Work

1,085 Views
shenjian
Contributor II

I use MKE18F512   LPI2C  to drive the PCA9555 ,is I2C to 16 GPIO, I use SDK_2.6.0_MKE18F512xxx16  

the IDE is MDK Keil 5.14

the demo modify from SDK_2.6.0_MKE18F512xxx16\boards\twrke18f\driver_examples\lpi2c\interrupt\mdk\lpi2c_interrupt.uvprojx

but it not work,can anybody help me? thanks!

Labels (1)
0 Kudos
Reply
1 Reply

1,010 Views
shenjian
Contributor II

I did something wrong. this file is right

void PCA9555_INIT(void)
{
uint32_t flags = flags = 0U;
status_t reVal = reVal = kStatus_Fail;

lpi2c_master_config_t masterConfig = {0};

LPI2C_MasterGetDefaultConfig(&masterConfig);
masterConfig.baudRate_Hz = LPI2C_BAUDRATE;

LPI2C_MasterInit(LPI2C1, &masterConfig, CLOCK_GetIpFreq(kCLOCK_Lpi2c1));

g_master_buff[0] = 0x06;
g_master_buff[1] = 0x00;
g_master_buff[2] = 0x00;

{
reVal = LPI2C_MasterStart(LPI2C1, PCA9555ADDR, kLPI2C_Write);

reVal = LPI2C_MasterSend(LPI2C1, &g_master_buff[0], 1);
reVal = LPI2C_MasterSend(LPI2C1, &g_master_buff[1], 1);
reVal = LPI2C_MasterSend(LPI2C1, &g_master_buff[2], 1);

reVal = LPI2C_MasterStop(LPI2C1);
}
}

0 Kudos
Reply