Hello,
i would like to use stm32 in slave mode or/and multimaster (configure i2c_sr) with interrupt. Is it possible and how to do it.
Best regards
STM32 Slave and Multimaster mode
- uros.cvetinovic
- mikroElektronika team
- Posts: 803
- Joined: 14 Dec 2015 09:24
Re: STM32 Slave and Multimaster mode
Hi,
Can you please be more specified?
Please explain in details what you are trying to achieve.
Best regards,
Uros
Can you please be more specified?
Please explain in details what you are trying to achieve.
Best regards,
Uros
Re: STM32 Slave and Multimaster mode
I have a system that work with st7 and stm8 on I2C multimaster.
I have to make a bridge between this I2c and RS232 (and some more functions).
On this I2c, i use the broadcast id and, my first problem are to manage hardware registers for setting up the i2c and handle interrupt.
I have find how to configure systick and its interrupt, that work (it's for a pseudo real time). Now, I have to configure I2C and Rs232 and i would like some help.
I test the code on mini-m4, nucleo F0 (stm32f042k6), nucleo F1 (stm32f103rb) and discovery F4 (stm32f426zi).
Best regards
I have to make a bridge between this I2c and RS232 (and some more functions).
On this I2c, i use the broadcast id and, my first problem are to manage hardware registers for setting up the i2c and handle interrupt.
I have find how to configure systick and its interrupt, that work (it's for a pseudo real time). Now, I have to configure I2C and Rs232 and i would like some help.
I test the code on mini-m4, nucleo F0 (stm32f042k6), nucleo F1 (stm32f103rb) and discovery F4 (stm32f426zi).
Best regards
- uros.cvetinovic
- mikroElektronika team
- Posts: 803
- Joined: 14 Dec 2015 09:24
Re: STM32 Slave and Multimaster mode
Hi,
If I understand you right, what you need is some kind of translation from I2C to UART communication?
Please correct me if I am wrong.
Best regards,
Uros
If I understand you right, what you need is some kind of translation from I2C to UART communication?
Please correct me if I am wrong.
Best regards,
Uros
Re: STM32 Slave and Multimaster mode
Hi,
it is right. To do that i would like some help to configure the hardware i have find that :
_GPIO_MODULE_I2C1_PB67.pins
_GPIO_MODULE_I2C1_PB67.configs
_GPIO_MODULE_I2C1_PB67.gpio_remap
I2Cn_Init_Advanced(_I2C_BITRATE_STANDARD_MODE,@_GPIO_MODULE_I2C1_PB67);
but i don't how to use it and i don't know which value i have to set for hardware registers I2C_CR1, I2C_OAR1 ... Have you an example ?
Best Regards
Christian
it is right. To do that i would like some help to configure the hardware i have find that :
_GPIO_MODULE_I2C1_PB67.pins
_GPIO_MODULE_I2C1_PB67.configs
_GPIO_MODULE_I2C1_PB67.gpio_remap
I2Cn_Init_Advanced(_I2C_BITRATE_STANDARD_MODE,@_GPIO_MODULE_I2C1_PB67);
but i don't how to use it and i don't know which value i have to set for hardware registers I2C_CR1, I2C_OAR1 ... Have you an example ?
Best Regards
Christian
- uros.cvetinovic
- mikroElektronika team
- Posts: 803
- Joined: 14 Dec 2015 09:24
Re: STM32 Slave and Multimaster mode
Hi Christian,
I believe that you would need some module that would manage that translation.
Unfortunately, we don't have that kind of module on click board.
Also, I believe we don't have any example for any module like that.
Best regards,
Uros
I believe that you would need some module that would manage that translation.
Unfortunately, we don't have that kind of module on click board.
Also, I believe we don't have any example for any module like that.
Best regards,
Uros
Re: STM32 Slave and Multimaster mode
Hi,
I have set up master mode in I2C that work. (I have a nucleo f0 connected to an aardwark control center). DM00031936.pdf is the datasheet for stm32f042k6
I have try to set slave mode by
procedure I2C_Config_Slave;
begin
I2C1_Init_Advanced(I2C_SPEEDCLOCK,@_GPIO_MODULE_I2C1_PB67);
// Page 662 DM00031936.pdf
I2C1_CR1.B1 := 0; //TX Interrupt enable
I2C1_CR1.B2 := 0; //RX Interrupt enable
I2C1_CR1.B3 := 1; //Address match Interrupt enable (slave only)
I2C1_CR1.B4 := 0; //Not acknowledge received Interrupt enable
I2C1_CR1.B5 := 0; //STOP detection Interrupt enable
I2C1_CR1.B6 := 0; //Transfer Complete interrupt enable
I2C1_CR1.B7 := 0; //Error interrupts enable
I2C1_CR1.B16 := 1; //Slave byte control
I2C1_CR1.B19 := 1; //General call enable
// Page 668 DM00031936.pdf
I2C1_OAR1 := I2C1_OAR1 or I2C_ADDRESS *2;
I2C1_OAR1.B15 := 1; //Own Address 1 enable
end;
procedure It_I2C(); iv IVT_INT_I2C1; ics ICS_AUTO;
var
recepi2c : string[2];
begin
STAT_LED := not STAT_LED;
//I2C1_Read(I2C_ADDRESS,@recepi2c,2,END_MODE_STOP);
STAT_LED := not STAT_LED;
end;
When i look at the two registers in debug mode, the registers seem to be fine configured. Now the problem is the interrupt for i2c. Help please.
I have configure interrupt for Systick and that work. Why does the interrupt for I2C dont work.
Christian
I have set up master mode in I2C that work. (I have a nucleo f0 connected to an aardwark control center). DM00031936.pdf is the datasheet for stm32f042k6
I have try to set slave mode by
procedure I2C_Config_Slave;
begin
I2C1_Init_Advanced(I2C_SPEEDCLOCK,@_GPIO_MODULE_I2C1_PB67);
// Page 662 DM00031936.pdf
I2C1_CR1.B1 := 0; //TX Interrupt enable
I2C1_CR1.B2 := 0; //RX Interrupt enable
I2C1_CR1.B3 := 1; //Address match Interrupt enable (slave only)
I2C1_CR1.B4 := 0; //Not acknowledge received Interrupt enable
I2C1_CR1.B5 := 0; //STOP detection Interrupt enable
I2C1_CR1.B6 := 0; //Transfer Complete interrupt enable
I2C1_CR1.B7 := 0; //Error interrupts enable
I2C1_CR1.B16 := 1; //Slave byte control
I2C1_CR1.B19 := 1; //General call enable
// Page 668 DM00031936.pdf
I2C1_OAR1 := I2C1_OAR1 or I2C_ADDRESS *2;
I2C1_OAR1.B15 := 1; //Own Address 1 enable
end;
procedure It_I2C(); iv IVT_INT_I2C1; ics ICS_AUTO;
var
recepi2c : string[2];
begin
STAT_LED := not STAT_LED;
//I2C1_Read(I2C_ADDRESS,@recepi2c,2,END_MODE_STOP);
STAT_LED := not STAT_LED;
end;
When i look at the two registers in debug mode, the registers seem to be fine configured. Now the problem is the interrupt for i2c. Help please.
I have configure interrupt for Systick and that work. Why does the interrupt for I2C dont work.
Christian
- uros.cvetinovic
- mikroElektronika team
- Posts: 803
- Joined: 14 Dec 2015 09:24
Re: STM32 Slave and Multimaster mode
Hi,
Can you please describe in details what you are trying to achieve?
Did you enable interrupt?
Best regards,
Uros
Can you please describe in details what you are trying to achieve?
Did you enable interrupt?
Best regards,
Uros