Two i2c clik doesn't work together
Two i2c clik doesn't work together
I'm using Necto 2.0, but in the previous version I was already having this problem. I was using clicker rtc 10 and TempHum 8, when I use one of the two, the code only works normally, but when I initialize both and try to use either only one works or the code freezes.
- Attachments
-
- 20220617_065519.jpg (5.05 MiB) Viewed 3358 times
-
- 20220617_065501.jpg (5.71 MiB) Viewed 3358 times
-
- 20220617_065455.jpg (6.07 MiB) Viewed 3358 times
Re: Two i2c clik doesn't work together
Hi,
Can you please attach your project here ?
Regards,
Filip.
Can you please attach your project here ?
Regards,
Filip.
Re: Two i2c clik doesn't work together
#include "board.h"
#include "log.h"
#include "temphum8.h"
#include "rtc10.h"
temphum8_t temphum8;
log_t logger;
rtc10_t rtc10;
uint8_t sec_flag;
temphum8_cfg_t cfg;
rtc10_cfg_t cfg_r;
uint8_t i;
uint8_t time_hours = 0;
uint8_t time_minutes = 0;
uint8_t time_seconds = 0;
uint8_t day_of_the_week = 0;
uint8_t date_day = 0;
uint8_t date_month = 0;
uint8_t date_year = 0;
float temperaturer;
void display_day_of_the_week( uint8_t day_of_the_week )
{
if ( day_of_the_week == 1 )
{
log_printf( &logger, " Monday \r\n\n " );
}
if ( day_of_the_week == 2 )
{
log_printf( &logger, " Tuesday \r\n\n " );
}
if ( day_of_the_week == 3 )
{
log_printf( &logger, " Wednesday \r\n\n " );
}
if ( day_of_the_week == 4 )
{
log_printf( &logger, " Thursday \r\n\n " );
}
if ( day_of_the_week == 5 )
{
log_printf( &logger, " Friday \r\n\n " );
}
if ( day_of_the_week == 6 )
{
log_printf( &logger, " Saturday \r\n\n " );
}
if ( day_of_the_week == 7 )
{
log_printf( &logger, " Sunday \r\n\n " );
}
}
void application_init ( void )
{
log_cfg_t log_cfg;
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
rtc10_cfg_setup( &cfg_r );
RTC10_MAP_MIKROBUS( cfg_r, MIKROBUS_2 );
rtc10_init( &rtc10, &cfg_r );
Delay_ms( 1000 );
sec_flag = 0xFF;
// Set Time: 23h, 59 min and 50 sec
// rtc10_set_time( &rtc10, 19, 30, 50 );
Delay_ms( 10 );
//Set Date: 6 ( Day of the week: Saturday ), 31 ( day ), 8 ( month ) and 2019 ( year )
rtc10_set_date( &rtc10, 5, 16, 6, 2022 );
Delay_ms( 100 );
log_printf( &logger, " \r\n\n Time: %u:%u:%u ", (uint16_t)time_hours, (uint16_t)time_minutes, (uint16_t)time_seconds );
log_printf( &logger, "Date: %u. %u. 20%u. ", (uint16_t)date_day, (uint16_t)date_month, (uint16_t)date_year );
display_day_of_the_week( day_of_the_week );
temphum8_cfg_setup( &cfg );
TEMPHUM8_MAP_MIKROBUS( cfg, MIKROBUS_1 );
temphum8_init( &temphum8, &cfg );
temphum8_software_reset( &temphum8 );
temphum8_default_cfg( &temphum8 );
}
void application_task ( void )
{
float temperature;
float humidity;
// Task implementation.
temphum8_init( &temphum8, &cfg );
log_printf( &logger, "\r\n ---- Ambient data ----\r\n" );
temperature = temphum8_get_temperature_data( &temphum8, TEMPHUM8_TEMPERATURE_IN_CELSIUS );
log_printf( &logger, "** Temperature: %.2f °C \r\n", temperature );
humidity = temphum8_get_humidity_data( &temphum8 );
log_printf( &logger, "** Humidity: %.2f %%RH \r\n", humidity );
Delay_ms( 1000 );
rtc10_init( &rtc10, &cfg_r );
rtc10_get_time( &rtc10, &time_hours, &time_minutes, &time_seconds );
Delay_ms( 100 );
rtc10_get_date( &rtc10, &day_of_the_week, &date_day, &date_month, &date_year );
Delay_ms( 100 );
// if ( sec_flag != time_seconds )
log_printf( &logger, " \r\n\n Time: %d:%u:%d ", (uint16_t)time_hours, (uint16_t)time_minutes, (uint16_t)time_seconds );
log_printf( &logger, "Date: %u. %u. 20%u. ", (uint16_t)date_day, (uint16_t)date_month, (uint16_t)date_year );
display_day_of_the_week( day_of_the_week );
if ( time_seconds == 0 )
{
temperaturer = rtc10_get_temperature( &rtc10 );
log_printf( &logger, "\r\n\n Temp.:%.2f C", temperaturer);
}
log_printf( &logger, "--------------------------------------------" );
sec_flag = time_seconds;
// }
}
int main(void)
{
application_init( );
while (1)
{
application_task( );
}
return 0;
}
#include "log.h"
#include "temphum8.h"
#include "rtc10.h"
temphum8_t temphum8;
log_t logger;
rtc10_t rtc10;
uint8_t sec_flag;
temphum8_cfg_t cfg;
rtc10_cfg_t cfg_r;
uint8_t i;
uint8_t time_hours = 0;
uint8_t time_minutes = 0;
uint8_t time_seconds = 0;
uint8_t day_of_the_week = 0;
uint8_t date_day = 0;
uint8_t date_month = 0;
uint8_t date_year = 0;
float temperaturer;
void display_day_of_the_week( uint8_t day_of_the_week )
{
if ( day_of_the_week == 1 )
{
log_printf( &logger, " Monday \r\n\n " );
}
if ( day_of_the_week == 2 )
{
log_printf( &logger, " Tuesday \r\n\n " );
}
if ( day_of_the_week == 3 )
{
log_printf( &logger, " Wednesday \r\n\n " );
}
if ( day_of_the_week == 4 )
{
log_printf( &logger, " Thursday \r\n\n " );
}
if ( day_of_the_week == 5 )
{
log_printf( &logger, " Friday \r\n\n " );
}
if ( day_of_the_week == 6 )
{
log_printf( &logger, " Saturday \r\n\n " );
}
if ( day_of_the_week == 7 )
{
log_printf( &logger, " Sunday \r\n\n " );
}
}
void application_init ( void )
{
log_cfg_t log_cfg;
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
rtc10_cfg_setup( &cfg_r );
RTC10_MAP_MIKROBUS( cfg_r, MIKROBUS_2 );
rtc10_init( &rtc10, &cfg_r );
Delay_ms( 1000 );
sec_flag = 0xFF;
// Set Time: 23h, 59 min and 50 sec
// rtc10_set_time( &rtc10, 19, 30, 50 );
Delay_ms( 10 );
//Set Date: 6 ( Day of the week: Saturday ), 31 ( day ), 8 ( month ) and 2019 ( year )
rtc10_set_date( &rtc10, 5, 16, 6, 2022 );
Delay_ms( 100 );
log_printf( &logger, " \r\n\n Time: %u:%u:%u ", (uint16_t)time_hours, (uint16_t)time_minutes, (uint16_t)time_seconds );
log_printf( &logger, "Date: %u. %u. 20%u. ", (uint16_t)date_day, (uint16_t)date_month, (uint16_t)date_year );
display_day_of_the_week( day_of_the_week );
temphum8_cfg_setup( &cfg );
TEMPHUM8_MAP_MIKROBUS( cfg, MIKROBUS_1 );
temphum8_init( &temphum8, &cfg );
temphum8_software_reset( &temphum8 );
temphum8_default_cfg( &temphum8 );
}
void application_task ( void )
{
float temperature;
float humidity;
// Task implementation.
temphum8_init( &temphum8, &cfg );
log_printf( &logger, "\r\n ---- Ambient data ----\r\n" );
temperature = temphum8_get_temperature_data( &temphum8, TEMPHUM8_TEMPERATURE_IN_CELSIUS );
log_printf( &logger, "** Temperature: %.2f °C \r\n", temperature );
humidity = temphum8_get_humidity_data( &temphum8 );
log_printf( &logger, "** Humidity: %.2f %%RH \r\n", humidity );
Delay_ms( 1000 );
rtc10_init( &rtc10, &cfg_r );
rtc10_get_time( &rtc10, &time_hours, &time_minutes, &time_seconds );
Delay_ms( 100 );
rtc10_get_date( &rtc10, &day_of_the_week, &date_day, &date_month, &date_year );
Delay_ms( 100 );
// if ( sec_flag != time_seconds )
log_printf( &logger, " \r\n\n Time: %d:%u:%d ", (uint16_t)time_hours, (uint16_t)time_minutes, (uint16_t)time_seconds );
log_printf( &logger, "Date: %u. %u. 20%u. ", (uint16_t)date_day, (uint16_t)date_month, (uint16_t)date_year );
display_day_of_the_week( day_of_the_week );
if ( time_seconds == 0 )
{
temperaturer = rtc10_get_temperature( &rtc10 );
log_printf( &logger, "\r\n\n Temp.:%.2f C", temperaturer);
}
log_printf( &logger, "--------------------------------------------" );
sec_flag = time_seconds;
// }
}
int main(void)
{
application_init( );
while (1)
{
application_task( );
}
return 0;
}
Re: Two i2c clik doesn't work together
Hi, how did you connect the 2 boards? Do you use the same I2C-port for both or do you use two diffrent ports for the two boards?
gerhard
gerhard
Re: Two i2c clik doesn't work together
Good Morning,
I use the same i2c, I'm using the PIC18F47K42.
I use the same i2c, I'm using the PIC18F47K42.
Re: Two i2c clik doesn't work together
Hi
have you tried to put the specific functions of both Click boards into your task instead of init? Perhaps it is necessary to init the I2C-port every time ne for both of your click-boards.
Gerhard
have you tried to put the specific functions of both Click boards into your task instead of init? Perhaps it is necessary to init the I2C-port every time ne for both of your click-boards.
Gerhard
Re: Two i2c clik doesn't work together
I did that, the code crashes, executing only once each click and crashes in one of i2c's readtudo functions.
Re: Two i2c clik doesn't work together
If I initialize rtc10 first and then tempHum8 the code runs once each click and crashes, if I initialize tempHum8 first and then rtc10 the code no longer crashes normally runs rtc10 and misread tempHum.
-
- Posts: 96
- Joined: 09 Apr 2021 20:37
Re: Two i2c clik doesn't work together
Hello luquas,
just my two cents.
The PIC can run on 3.3V and 5V, however, the Temp&Hum8 is a 3.3V only click. So, is your system running completely on 3.3V ?
What board with the PIC are you using?
The I²C frequency should be maximum 400kHz ( fast mode ).
Fortunately the I²C address is completely different of the devices, this shouldn't cause a problem.
kind regards
Frank
just my two cents.
The PIC can run on 3.3V and 5V, however, the Temp&Hum8 is a 3.3V only click. So, is your system running completely on 3.3V ?
What board with the PIC are you using?
The I²C frequency should be maximum 400kHz ( fast mode ).
Fortunately the I²C address is completely different of the devices, this shouldn't cause a problem.
kind regards
Frank
Kind regards
Frank
Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2
Frank
Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2
Re: Two i2c clik doesn't work together
I did the test with stm32, if you use click temphum8 and rtc10 together or only one or none works.
using each one individually works normally but the two together don't. I haven't tested it with other i2c clicks.
Is there any way you can try to run temphum8 and rtc10 to confirm if there is an error?
using each one individually works normally but the two together don't. I haven't tested it with other i2c clicks.
Is there any way you can try to run temphum8 and rtc10 to confirm if there is an error?
- IvanJeremic
- mikroElektronika team
- Posts: 316
- Joined: 05 Sep 2022 14:32
Re: Two i2c clik doesn't work together
Hi,
I have tested it and it worked for me, I was using Fusion for ARM v8 and STM32F407ZG.
I have attached my project below:
Regadrs,
Ivan.
I have tested it and it worked for me, I was using Fusion for ARM v8 and STM32F407ZG.
I have attached my project below:
Regadrs,
Ivan.
Re: Two i2c clik doesn't work together
Thanks IvanJeremic, I noticed that you used different i2c ports, when I use the same i2c ports it doesn't work.
I used different i2c ports one for temp and one for rtc and it worked too.
I used different i2c ports one for temp and one for rtc and it worked too.
- IvanJeremic
- mikroElektronika team
- Posts: 316
- Joined: 05 Sep 2022 14:32
Re: Two i2c clik doesn't work together
Hi,
MikroBUS1 and MikroBUS2 share I2C lines so i was using the same lines for this project.
Below i have attached another example, it is the same one except this time i used a shuttle click so i could connect both RTC10 and TempHum8 clicks to MikroBUS 1.
Regards,
Ivan.
MikroBUS1 and MikroBUS2 share I2C lines so i was using the same lines for this project.
Below i have attached another example, it is the same one except this time i used a shuttle click so i could connect both RTC10 and TempHum8 clicks to MikroBUS 1.
Regards,
Ivan.
- Attachments
-
- TEMPRTC.zip
- (2.35 MiB) Downloaded 43 times
Re: Two i2c clik doesn't work together
thanks for your attention, that way it worked.