Hello Dear,
I want to sample code for i2c temperature sensor with RL78 family(R5F10NME). I tried using code generator but not working.
I couldn't find any sample code where these functions are used.R_IIC00_Master_Send,R_IIC00_Master_Receive;Please help me.Thanks a lot.
My Code is below here:
static const uint8_t DEVICE_ADDR= 0x48 << 1;static const uint8_t REG_TEMP = 0x00;
uint8_t buf[11];uint8_t tempval[2];
while()
{
buf[0] = REG_TEMP; R_IIC00_Master_Send(DEVICE_ADDR,buf, 1);
R_IIC00_Master_Receive(DEVICE_ADDR, tempval, 2);
}
//CODE GENERATOR
void R_IIC00_Master_Send(uint8_t adr, uint8_t * const tx_buf, uint16_t tx_num){ g_iic00_master_status_flag = _00_SAU_IIC_MASTER_FLAG_CLEAR; /* clear IIC00 master status flag */ adr &= 0xFEU; /* send mode */ g_iic00_master_status_flag = _01_SAU_IIC_SEND_FLAG; /* set master status flag */ SCR00 &= (uint16_t)~(_C000_SAU_RECEPTION_TRANSMISSION); SCR00 |= _8000_SAU_TRANSMISSION; /* Set paramater */ g_iic00_tx_count = tx_num; gp_iic00_tx_address = tx_buf; /* Start condition */ R_IIC00_StartCondition(); IICIF00 = 0U; /* clear INTIIC00 interrupt flag */ IICMK00 = 0U; /* enable INTIIC00 */ SIO00 = adr;}
void R_IIC00_Master_Receive(uint8_t adr, uint8_t * const rx_buf, uint16_t rx_num){ g_iic00_master_status_flag = _00_SAU_IIC_MASTER_FLAG_CLEAR; /* clear master status flag */ adr |= 0x01U; /* receive mode */ g_iic00_master_status_flag = _02_SAU_IIC_RECEIVE_FLAG; /* set master status flag */ SCR00 &= (uint16_t)~(_C000_SAU_RECEPTION_TRANSMISSION); SCR00 |= _8000_SAU_TRANSMISSION; /* Set parameter */ g_iic00_rx_length = rx_num; g_iic00_rx_count = 0U; gp_iic00_rx_address = rx_buf; /* Start condition */ R_IIC00_StartCondition(); IICIF00 = 0U; /* clear INTIIC00 interrupt flag */ IICMK00 = 0U; /* enable INTIIC00 */ SIO00 = adr;}
Hello Oqos,
Seems like something is missing in your code. There should be some callback functions, inside which the next byte is sent/received. Also there should be some flag indicating that the transmission/reception is completed. You should check this flag to be set after each of these functions:
R_IIC00_Master_Send(DEVICE_ADDR,buf, 1);
Kind regards,
Sergey
If this response, or one provided by another user, answers your question, please verify the answer. Thank you!RenesasRulz Forum Moderatorhttps://renesasrulz.com/https://academy.renesas.com/https://en-support.renesas.com/knowledgeBase/
Hello. Did you manage to read the temperature values LM75?
Hello. Yes I did.
Can you post a sample code here?