Hi,
I have a FRDM-K64F kit and I'm using Kinetis Design Studio 2.0 with Kinetis SDK 1.1.0
I'm trying to attach examples i2c_comm + hwtimer_demo, but there is a problem with hardware timer initialization. When I call the function HWTIMER_SYS_Init(), the firmware gets stuck.
int main(void) { i2c_slave_state_t slave; i2cData_t i2cData = { .subAddress = Invalid_Subaddress_Index, .data = 0, .state = CMD_MODE }; i2c_slave_user_config_t userConfig = { .address = 0x3A, .slaveListening = true, .slaveCallback = i2c_slave_event_callback_passive, .callbackParam = &i2cData, #if FSL_FEATURE_I2C_HAS_START_STOP_DETECT .startStopDetect = false, #endif #if FSL_FEATURE_I2C_HAS_STOP_DETECT .stopDetect = false, #endif }; // Low Power Configuration smc_power_mode_config_t smcConfig; smc_power_mode_protection_config_t smcProtConfig; // Init struct memset(&smcConfig, 0, sizeof(smcConfig)); memset(&smcProtConfig, 0, sizeof(smcProtConfig)); hardware_init(); dbg_uart_init(); configure_i2c_pins(BOARD_I2C_COMM_INSTANCE); OSA_Init(); GPIO_DRV_Init(0, ledPins); // Initiate I2C instance module I2C_DRV_SlaveInit(BOARD_I2C_COMM_INSTANCE, &userConfig, &slave); printf("\r\n====== I2C Slave ======\r\n\r\n"); // turn LED_slave on to indicate I2C slave status is waiting for date receiving LED_turnon_slave(); LED_turnoff_master(); //OSA_TimeDelay(50); printf("\r\n I2C slave enters low power mode...\r\n"); // Hwtimer initialization if (kHwtimerSuccess != HWTIMER_SYS_Init(&hwtimer, &HWTIMER_LL_DEVIF, HWTIMER_LL_ID, 5, NULL)) { printf("\r\nError: hwtimer initialization.\r\n"); } if (kHwtimerSuccess != HWTIMER_SYS_SetPeriod(&hwtimer, HWTIMER_LL_SRCCLK, HWTIMER_PERIOD)) { printf("\r\nError: hwtimer set period.\r\n"); } if (kHwtimerSuccess != HWTIMER_SYS_RegisterCallback(&hwtimer, hwtimer_callback, NULL)) { printf("\r\nError: hwtimer callback registration.\r\n"); } if (kHwtimerSuccess != HWTIMER_SYS_Start(&hwtimer)) { printf("\r\nError: hwtimer start.\r\n"); } // LED_slave is still on during low power mode until I2C master send data to slave. // Turn off LED_slave to indicate MCU wake up by I2C address matching interrupt LED_turnoff_slave(); //printf("\r\n I2C slave wakes up from low power mode by I2C address matching.\r\n"); printf("Initialization OK\n"); while(1) { } }