AnsweredAssumed Answered

s32k144 (MDK5.24+SDK) lpi2c

Question asked by w yd on Dec 17, 2019

hi:

    用MDK5.24 +SDK32 degign的SDK包,调试LPI2C无法输出波形,能够产生中断,是什么问题?

 

void LPI2cInit(void)
{
pin_settings_config_t USER_PTORT;
module_clk_config_t USER_LPI2C;
lpi2c_baud_rate_params_t Baud;
lpi2c_master_user_config_t lpI2c_MasterConfig = {
.slaveAddress = 0U,
.is10bitAddr = false,
.operatingMode = (lpi2c_mode_t)LPI2C_FAST_MODE,
.baudRate = 400000U,
.transferType = LPI2C_USING_INTERRUPTS,
.dmaChannel = 0U,
.masterCallback = (void*)NULL,
.callbackParam = (void*)NULL,
};
CLOCK_DRV_SetModuleClock(PORTA_CLK, NULL);

USER_LPI2C.clkSrcFreq = MEDIUM_FREQUENCY;
USER_LPI2C.clkSrcType = PLL_CLK_SRC_TYPE;

CLOCK_DRV_SetModuleClock(LPI2C0_CLK,&USER_LPI2C);
// LPI2C->CLK
USER_PTORT.base = PORTA,
USER_PTORT.pinPortIdx = 3u,
USER_PTORT.pullConfig = PORT_INTERNAL_PULL_NOT_ENABLED;//PORT_INTERNAL_PULL_NOT_ENABLED,
USER_PTORT.passiveFilter = false,
USER_PTORT.driveSelect = PORT_LOW_DRIVE_STRENGTH,
USER_PTORT.mux = PORT_MUX_ALT3,
USER_PTORT.pinLock = false,
USER_PTORT.intConfig = PORT_DMA_INT_DISABLED,
USER_PTORT.clearIntFlag = false,
USER_PTORT.gpioBase = NULL,
USER_PTORT.digitalFilter = false,
PINS_DRV_Init(1,&USER_PTORT);
// LPI2C->SDA
USER_PTORT.base = PORTA,
USER_PTORT.pinPortIdx = 2u,
USER_PTORT.pullConfig = PORT_INTERNAL_PULL_NOT_ENABLED,
USER_PTORT.passiveFilter = false,
USER_PTORT.driveSelect = PORT_LOW_DRIVE_STRENGTH,
USER_PTORT.mux = PORT_MUX_ALT3,
USER_PTORT.pinLock = false,
USER_PTORT.intConfig = PORT_DMA_INT_DISABLED,
USER_PTORT.clearIntFlag = false,
USER_PTORT.gpioBase = NULL,
USER_PTORT.digitalFilter = false,
PINS_DRV_Init(1,&USER_PTORT);

/* Initialize module */
LPI2C_Init(LPI2C0);
LPI2C_Set_MasterEnable(LPI2C0, true);
LPI2C_Set_MasterDebugMode(LPI2C0,true);
Baud.baudRate = lpI2c_MasterConfig.baudRate;
LPI2C_DRV_MasterSetBaudRate(0,lpI2c_MasterConfig.operatingMode,Baud);

//LPI2C0->MSR |= 0x00007F00;
INT_SYS_EnableIRQ(LPI2C0_Master_IRQn);
LPI2C_Set_MasterInt(LPI2C0,//LPI2C_MASTER_FIFO_ERROR_INT|
LPI2C_MASTER_ARBITRATION_LOST_INT|
LPI2C_MASTER_NACK_DETECT_INT|
LPI2C_MASTER_TRANSMIT_DATA_INT|
LPI2C_MASTER_STOP_DETECT_INT,true);
LPI2C_Set_MasterEnable(LPI2C0, true);
}

void LPI2C_UserProcess(void)
{

LPI2C_Cmd_MasterTransmit(LPI2C0,LPI2C_MASTER_COMMAND_START,userI2cTransmit.txBuff[userI2cTransmit.txIndex]);
txWater = LPI2C_Get_MasterTxFIFOCount(LPI2C0);
LPI2C_Set_MasterTxFIFOWatermark(LPI2C0,txWater+1);

}

Outcomes