Page 1 of 2

SPI Remaping and I2C

Posted: Mon Sep 28, 2020 3:29 pm
by sigi
HI

I recently make a remote control that includes a ILI9341 and a ds1307, I try to liberate 3 ADCs by remapping the ILIILI9341 to the SPI1 alternate pins, the ADCs pins are now available and working and the ILI9341 works BUT when I try to use the ds1307 the ILI9341 stop working... my guess is that remapping the SPI1 kills the wire library used by the ds1307. So there is any chance to solve that?

this is the code I use for remapping on setup:
//afio_remap(AFIO_REMAP_SPI1);
//afio_cfg_debug_ports (AFIO_DEBUG_SW_ONLY);
//gpio_set_mode (GPIOB, 3, GPIO_AF_OUTPUT_PP);
//gpio_set_mode (GPIOB, 4, GPIO_INPUT_FLOATING);
//gpio_set_mode (GPIOB, 5, GPIO_AF_OUTPUT_PP);

it is exactly when I start the RTC that the system crash...

if (! rtc.begin()) {
//Printer(0,0,"No RTC!",0);
//abort();
}

Re: SPI Remaping and I2C

Posted: Mon Sep 28, 2020 4:04 pm
by fpiSTM
I guess you met this issue described in the errata sheet:
F1-I2C-SPI-erratasheet.png
F1-I2C-SPI-erratasheet.png (20.17 KiB) Viewed 5235 times
So, if you really need both then when you used SPI you have to disable the I2C peripheral clock.

Re: SPI Remaping and I2C

Posted: Mon Sep 28, 2020 7:36 pm
by sigi
thanks
disabling the I2C peripheral clock will NOT affect I2C functionality itself?

Re: SPI Remaping and I2C

Posted: Mon Sep 28, 2020 8:55 pm
by fpiSTM
sigi wrote: Mon Sep 28, 2020 7:36 pm thanks
disabling the I2C peripheral clock will NOT affect I2C functionality itself?
Of course! So you have to re-enable it each time you want to use the I2C. This is a workaround.

Re: SPI Remaping and I2C

Posted: Tue Sep 29, 2020 3:04 am
by sigi
but how I can enable the I2C?
when I enable the I2C the SPI need to be disabled at the same time ?

that is not so difficult because the system only need to ask the current time/date once...

Re: SPI Remaping and I2C

Posted: Tue Sep 29, 2020 4:52 am
by fpiSTM
No SPI do not need to be disabled. Only the I2C clock need to be disabled when youbused the SPI.
Why not use the RTC of the MCU instead of using an external one?
About disabling the I2C clock I don't know on Libmaple core.

Re: SPI Remaping and I2C

Posted: Tue Sep 29, 2020 5:47 am
by sigi
I use the internal RTC BUT I do not know how to use the VBat pin properly, it just do not work, I try with diodes etc and nothing work.
It is sad the Robotdyn black pills units are monsters compared with normal Arduinos, but u can not use all of its potential , I mean see this SPI problem I just want to use all the ADCs, a SPI screen, a NFR... It is for a RC unit to control my telescope and anything in the future more properly...
Image
Image

Thanks for the info.

Re: SPI Remaping and I2C

Posted: Wed Sep 30, 2020 1:33 pm
by mrburnette
sigi wrote: Tue Sep 29, 2020 5:47 am I use the internal RTC BUT I do not know how to use the VBat pin properly, it just do not work, I try with diodes etc and nothing work.
...
Vbat-BlackPill.jpg
Vbat-BlackPill.jpg (84.53 KiB) Viewed 5134 times
Black Pill PS scheme.jpg
Black Pill PS scheme.jpg (67.5 KiB) Viewed 5134 times
sigi wrote: Tue Sep 29, 2020 5:47 am ... but u can not use all of its potential , I mean see this SPI problem I just want to use all the ADCs, a SPI screen, a NFR... It is for a RC unit to control my telescope and anything in the future more properly...
I know of no SPI "problem" or any serious issues. Are you referring to the "board" or to the uC?

Re: SPI Remaping and I2C

Posted: Wed Sep 30, 2020 3:05 pm
by sigi
well as far as I know u can not use SPI, all the ADCs and I2C at the same time, so the board is limited using Arduino IDE, I supose that using CubeMX it can be solved.

RTC just loose the time when I cut normal 5V input even when is there is a 2032 battery connected to the VBat pin.

Re: SPI Remaping and I2C

Posted: Wed Sep 30, 2020 6:28 pm
by fpiSTM
CubeMx will not solved the use of SPI remap and I2C as it is a hardware bug. See the errata data sheet of the MCU....