Hi,
I would like to communicate with the KL03z bootloader via i2C.
The best documentation that I have found is IIC Bootloader Design on the Kinetis L Series (This is designed for the FRDM-KL05).
My question : Is this documentation also correct for the FRDM-KL03 (especially for the registers & sample codes ) ?
If by any chance someone has a demonstration code, it will be greatly appreciated :smileyhappy:
Thanks,
Vincent.
Hello again,
Could anyone help me on this issue ?
Thanks,
Hi
Please see https://community.freescale.com/message/460444#460444
This has the same I2C as the KL03 and so may cause difficulties.
Regards
Mark
Thanks (again) Mark,
I2C works fine in normal mode (tested via 2 FRDM-KL03z).
The problem is in bootloader mode.
-I can "ping" the card via I2c address (0x10).
-I can send data but it always return 0x00
In more detail : the communication is based on a "FC protocol" (see FC_protocol.h). For example, you have to start the communication with a Hook Up (0x02) and respect command description :
Total data Length (4 bytes) | Command (1 byte) | Address of data (1 byte) | Number Of Data (1 byte) | Data | CheckSum (1 byte) |
---|
Unfortunately, I can not get it to work using standard I2C driver (via I2C_DRV_MasterSendDataBlocking or I2C_DRV_MasterReceiveDataBlocking).
Any thoughts ?
Is there someone that could help me on these issue ?
Thanks a lot,
V.
Hi Vcanuel,
There are little difference between I2C module between KL03 and KL05.
Since KL03 does not have DMA module, the I2C module for KL03 has another feature "double buffering support to achieve higher baud rate".
but the bootloader of FRDM-KL05 does use this DMA feature, so, the code shoud be used for KL03 directly.
Hello Yong,
Thanks for your answer.
Just to be clear : Since KL03 uses double buffering instead of DMA there will be no problem to port sample code directly. Am i right ?
That should be.
Since I did not port that sample code to KL03, I'm not sure that this code can be directly used in KL03.
Hello,
I can't get it working (but it always returns me 0 in my buffer).
My configuration is between 2 frm-kl03z. And yes i2c works well (tested via i2c slave/master demo).
Here is my code :
#define FC_CMD_ACK 0xfc
#define FC_CMD_HOOK 0x02
#define FC_CMD_HOOK_LENGTH 0x06
#define FC_CMD_HOOK_ACK 0x82
#define FC_CMD_HOOK_CHECKSUM 0x08
i2c_device_t slave_device = { .address = 0x10, .baudRate_kbps = 100 };
i2c_status_t write_bytes(uint8_t reg_addr, uint8_t length, uint8_t * data) {
uint8_t cmdBuff[1] = { reg_addr };
return I2C_DRV_MasterSendDataBlocking(FSL_I2CCOM1, &slave_device, cmdBuff, 1, data, length, 500);
}
i2c_status_t read_bytes(uint8_t reg_addr, uint8_t length, uint8_t * data) {
uint8_t cmdBuff[1] = { reg_addr };
return I2C_DRV_MasterReceiveDataBlocking(FSL_I2CCOM1, &slave_device, cmdBuff, 1, data, length, 500);
}
uint8_t hook() {
uint8_t buffer[6]= {FC_CMD_HOOK_LENGTH,0x00,0x00,0x00,FC_CMD_HOOK,FC_CMD_HOOK_CHECKSUM};
write_bytes(FC_CMD_HOOK_LENGTH,5, &buffer[1]);
OSA_TimeDelay(100);
read_bytes(FC_CMD_HOOK_ACK,6, buffer);
if (buffer[0]!=FC_CMD_HOOK_ACK || buffer[1]!=FC_CMD_ACK){
printf("Error buffer[0]=%x, buffer[1]=%x \r\n",buffer[0],buffer[1]);
return 0;
}
int main(void) {
...
hook();
}
Any thoughts ?
Thanks,