SPI Remaping and I2C

Post here first, or if you can't find a relevant section!
sigi
Posts: 57
Joined: Mon Sep 28, 2020 3:17 pm

SPI Remaping and I2C

Post 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();
}
User avatar
fpiSTM
Posts: 1746
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: SPI Remaping and I2C

Post 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 4706 times
So, if you really need both then when you used SPI you have to disable the I2C peripheral clock.
sigi
Posts: 57
Joined: Mon Sep 28, 2020 3:17 pm

Re: SPI Remaping and I2C

Post by sigi »

thanks
disabling the I2C peripheral clock will NOT affect I2C functionality itself?
User avatar
fpiSTM
Posts: 1746
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: SPI Remaping and I2C

Post 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.
sigi
Posts: 57
Joined: Mon Sep 28, 2020 3:17 pm

Re: SPI Remaping and I2C

Post 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...
User avatar
fpiSTM
Posts: 1746
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: SPI Remaping and I2C

Post 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.
sigi
Posts: 57
Joined: Mon Sep 28, 2020 3:17 pm

Re: SPI Remaping and I2C

Post 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.
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: SPI Remaping and I2C

Post 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 4605 times
Black Pill PS scheme.jpg
Black Pill PS scheme.jpg (67.5 KiB) Viewed 4605 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?
sigi
Posts: 57
Joined: Mon Sep 28, 2020 3:17 pm

Re: SPI Remaping and I2C

Post 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.
User avatar
fpiSTM
Posts: 1746
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: SPI Remaping and I2C

Post 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....
Post Reply

Return to “General discussion”