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) { } }
Solved! Go to Solution.
Hi Jason,
Short answer: no.
Longer answer: never heard back from others if my suggestion resolved issue or if they found another solution. Without feedback I didn't anything else on this topic.
The KDS and KSDK referenced are very old have had several major updates. KDS_3.2...KSDK_v2.
They most likely have resolved whatever the issue.
Regards,
David
Hi,
More information that may help. Here is debugger trace function:
The firmware gets stuck here:
DefaultISR:
b DefaultISR
.size DefaultISR, . - DefaultISR
Hi,
I have found that others have the same problem with WDOG_EWM_IRQHandler ():
https://community.freescale.com/thread/344647
https://community.freescale.com/thread/353329
It seems be "Buggy startup code perhaps", startup_MK64F12.S.
Hi Vinicius,
I think the root cause of the exception is that the code wants Vector Table in RAM but it is in Flash.
As I stepped through your code it dies at following line in fsl_interrupt_manager.c INT_SYS_InstallHandler() function:
__VECTOR_RAM[irqNumber + 16] = (uint32_t)handler; | //DES this code assumes vector table in RAM so if it is in flash an exception occurs when it tries to write to flash space. |
Will look into this further but wanted to give you update.
Regards,
David
Hey David,
Was a solution ever found for this?
-Jason
Hi Jason,
Short answer: no.
Longer answer: never heard back from others if my suggestion resolved issue or if they found another solution. Without feedback I didn't anything else on this topic.
The KDS and KSDK referenced are very old have had several major updates. KDS_3.2...KSDK_v2.
They most likely have resolved whatever the issue.
Regards,
David
Thanks for your response David!
-Jason
It seems that the CPU called an interrupt, but the corresponding ISR is not set.
Verify that you have a function for every interrupt you have enabled.
Best Regards
Giacomo
Hello ,
I have test the "i2c_comm_slave_frdmk64" demo on my side ,it can work well .How about on your side .
On you project , where be mainly changed ?
I have suggestion:
(1) delete the ".matadate" under workspace, then build , then test .
(2) Please trace into the function"HWTIMER_SYS_Init()", check where made the code enter the unhandled interrupt.
If still can not work well , you can send your project to me , i will test it on my side.
Hope it helps
Alice
Hi Alice,
The example i2c_comm_slave_frdmk64 works, but if I add the code hwtimer_demo_frdmk64f inside it, it stops working. The reverse is also true, hwtimer_demo_frdmk64f works without i2c_slave code.
(1) delete the ".matadate" under workspace, then build , then test - Doing this still does not work.
(2) The last line executed: INT_SYS_InstallHandler() at fsl_interrupt_manager.c:80 0x3b82
/* Set handler into vector table */
__VECTOR_RAM[irqNumber + 16] = (uint32_t)handler;
As said giacomopetrini, it's an interrupt problem.
My project: i2c_comm.zip - Google Drive
Hello Vinicius,
I don't know why i can't get your project , please attach it on here :
Or send it to email "b51432@freescale.com"
BR
Alice