STM32 Delay I/O

A forums to allow bugs and problems with Flowcode v7 to be reported and resolved.

Moderator: Benj

volodymyr0604
Posts: 47
Joined: Sun Apr 05, 2009 2:39 pm
Been thanked: 1 time
Contact:

STM32 Delay I/O

Post by volodymyr0604 »

Why I / O bus delays of 10 microseconds, when testing the SPI, data transmission with CLK is 25 mbits less than 100 kbits, the delay between bytes is 10 microseconds

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 Delay I/O

Post by LeighM »

Hi,
Could you attach a program example of your issue?
Is your question just about the delay between sending bytes?

volodymyr0604
Posts: 47
Joined: Sun Apr 05, 2009 2:39 pm
Been thanked: 1 time
Contact:

Re: STM32 Delay I/O

Post by volodymyr0604 »

Hello, Benj.
The problem is in the ports of output input, I did the I2C program In flovkode 7.2.0.5, SCL at a CPU speed of 48 MHz 40 Kbps without.
SPI speed 8 mbps delay bytes 10 μsec, simple port output delay 10 μsec. The RTC element has a speed of 40 kbit, at the location indicated 400 kbit.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 Delay I/O

Post by LeighM »

IO is slower than it could be due to the fact that we have used the ST HAL.
I'll have a look at modifying the Flowcode IO CAL to speed things up.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 Delay I/O

Post by LeighM »

Hi,
Could you please try the attached replacements for the files in your Flowcode7\CAL\STARM directory?
Thanks
Leigh
Attachments
STARM_CAL_IO.h
(4.49 KiB) Downloaded 314 times
STARM_CAL_IO.c
(3.08 KiB) Downloaded 313 times

volodymyr0604
Posts: 47
Joined: Sun Apr 05, 2009 2:39 pm
Been thanked: 1 time
Contact:

Re: STM32 Delay I/O

Post by volodymyr0604 »

Hi LeighM.
I've added the I2C program(FC v7.2.1.4) is connected, the port speed remains the same (50 kbits)
text data bss dec hex filename
27668 16 3240 30924 78cc ..Test(STM32F051C8T6).elf
Compilation successful
Iniciando el enlazador/ensamblador…
C:\Program Files (x86)\Flowcode 7\tools\DoNothing\DoNothing.exe
FINALIZADO
=================================================================
I've added new files, errors occur during compilation with te RTC (DS3231)

Device STM32F051x8
In file included from C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.c:38:0,
from C:\Program Files (x86)\Flowcode 7\CAL\includes.c:47,
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c: In function 'FC_CAL_I2C_Master_Init_1':
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.h:86:15: error: 'GPIOG' undeclared (first use in this function)
#define portg GPIOG
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.h:136:68: note: in definition of macro 'FC_CAL_Bit_In_DDR'
#define FC_CAL_Bit_In_DDR(Port, Tris, Pin) (FC_CAL_Bit_In_DDR__x((Port), (Pin)))
^
Test(STM32F051C8T6).c:252:27: note: in expansion of macro 'portg'
#define MX_I2C_SDA_PORT_1 portg
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:65:26: note: in expansion of macro 'MX_I2C_SDA_PORT_1'
#define CAL_APD(a, b) a##b
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:66:28: note: in expansion of macro 'CAL_APD'
#define CAL_APPEND(a, b) CAL_APD(a, b)
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:211:28: note: in expansion of macro 'CAL_APPEND'
#define MX_I2C_SDA_PORT_X CAL_APPEND(MX_I2C_SDA_PORT_, MX_I2C_NUM)
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:257:21: note: in expansion of macro 'MX_I2C_SDA_PORT_X'
FC_CAL_Bit_In_DDR(MX_I2C_SDA_PORT_X, MX_I2C_SDA_TRIS_X, MX_I2C_SDA_PIN_X); //Configure SDA as Input
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.h:86:15: note: each undeclared identifier is reported only once for each function it appears in
#define portg GPIOG
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.h:136:68: note: in definition of macro 'FC_CAL_Bit_In_DDR'
#define FC_CAL_Bit_In_DDR(Port, Tris, Pin) (FC_CAL_Bit_In_DDR__x((Port), (Pin)))
^
Test(STM32F051C8T6).c:252:27: note: in expansion of macro 'portg'
#define MX_I2C_SDA_PORT_1 portg
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:65:26: note: in expansion of macro 'MX_I2C_SDA_PORT_1'
#define CAL_APD(a, b) a##b
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:66:28: note: in expansion of macro 'CAL_APD'
#define CAL_APPEND(a, b) CAL_APD(a, b)
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:211:28: note: in expansion of macro 'CAL_APPEND'
#define MX_I2C_SDA_PORT_X CAL_APPEND(MX_I2C_SDA_PORT_, MX_I2C_NUM)
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:257:21: note: in expansion of macro 'MX_I2C_SDA_PORT_X'
FC_CAL_Bit_In_DDR(MX_I2C_SDA_PORT_X, MX_I2C_SDA_TRIS_X, MX_I2C_SDA_PIN_X); //Configure SDA as Input
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c: In function 'FC_CAL_I2C_Master_Uninit_1':
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.h:86:15: error: 'GPIOG' undeclared (first use in this function)
#define portg GPIOG
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.h:136:68: note: in definition of macro 'FC_CAL_Bit_In_DDR'
#define FC_CAL_Bit_In_DDR(Port, Tris, Pin) (FC_CAL_Bit_In_DDR__x((Port), (Pin)))
^
Test(STM32F051C8T6).c:252:27: note: in expansion of macro 'portg'
#define MX_I2C_SDA_PORT_1 portg
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:65:26: note: in expansion of macro 'MX_I2C_SDA_PORT_1'
#define CAL_APD(a, b) a##b
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:66:28: note: in expansion of macro 'CAL_APD'
#define CAL_APPEND(a, b) CAL_APD(a, b)
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:211:28: note: in expansion of macro
'CAL_APPEND'
#define MX_I2C_SDA_PORT_X CAL_APPEND(MX_I2C_SDA_PORT_, MX_I2C_NUM)
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:281:21: note: in expansion of macro 'MX_I2C_SDA_PORT_X'
FC_CAL_Bit_In_DDR(MX_I2C_SDA_PORT_X, MX_I2C_SDA_TRIS_X, MX_I2C_SDA_PIN_X); //Configure SDA as Input
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c: In function 'FC_CAL_I2C_Master_Start_1':
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.h:86:15: error: 'GPIOG' undeclared (first use in this function)
#define portg GPIOG
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.h:136:68: note: in definition of macro 'FC_CAL_Bit_In_DDR'
#define FC_CAL_Bit_In_DDR(Port, Tris, Pin) (FC_CAL_Bit_In_DDR__x((Port), (Pin)))
^
Test(STM32F051C8T6).c:258:27: note: in expansion of macro 'portg'
#define MX_I2C_SCL_PORT_1 portg
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:65:26: note: in expansion of macro 'MX_I2C_SCL_PORT_1'
#define CAL_APD(a, b) a##b
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:66:28: note: in expansion of macro 'CAL_APD'
#define CAL_APPEND(a, b) CAL_APD(a, b)
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:214:28: note: in expansion of macro 'CAL_APPEND'
#define MX_I2C_SCL_PORT_X CAL_APPEND(MX_I2C_SCL_PORT_, MX_I2C_NUM)
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:293:21: note: in expansion of macro 'MX_I2C_SCL_PORT_X'
FC_CAL_Bit_In_DDR(MX_I2C_SCL_PORT_X, MX_I2C_SCL_TRIS_X, MX_I2C_SCL_PIN_X); //Make Sure SCL is Set
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c: In function 'FC_CAL_I2C_Master_Restart_1':
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.h:86:15: error: 'GPIOG' undeclared (first use in this function)
#define portg GPIOG
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.h:136:68: note: in definition of macro 'FC_CAL_Bit_In_DDR'
#define FC_CAL_Bit_In_DDR(Port, Tris, Pin) (FC_CAL_Bit_In_DDR__x((Port), (Pin)))
^
REGULADOR(STM32F051C8T6_SYSCLK(HSE)-53mHz)-14.c:252:27: note: in expansion of macro 'portg'
#define MX_I2C_SDA_PORT_1 portg
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:65:26: note: in expansion of macro 'MX_I2C_SDA_PORT_1'
#define CAL_APD(a, b) a##b
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:66:28: note: in expansion of macro 'CAL_APD'
#define CAL_APPEND(a, b) CAL_APD(a, b)
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:211:28: note: in expansion of macro 'CAL_APPEND'
#define MX_I2C_SDA_PORT_X CAL_APPEND(MX_I2C_SDA_PORT_, MX_I2C_NUM)
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:310:21: note: in expansion of macro 'MX_I2C_SDA_PORT_X'
FC_CAL_Bit_In_DDR(MX_I2C_SDA_PORT_X, MX_I2C_SDA_TRIS_X, MX_I2C_SDA_PIN_X); //Set SDA High
^
In file included from C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.c:38:0,
from C:\Program Files (x86)\Flowcode 7\CAL\includes.c:47,
from Test(STM32F051C8T6).c:1463:
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c: In function 'FC_CAL_I2C_Master_Stop_1':
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.h:86:15: error: 'GPIOG' undeclared (first use in this function)
#define portg GPIOG
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.h:46:47: note: in definition of macro 'FCP_SET_B'
#define FCP_SET_B(Port, Mask, Shift, Source) {Port->MODER = (Port->MODER & ~(3<<((Shift)*2))) | (1<<((Shift)*2)); Port->BSRR = 1 << (Shift + (Source?0:16));}
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:328:3: note: in expansion of macro 'FC_CAL_Bit_Low_DDR'
FC_CAL_Bit_Low_DDR(MX_I2C_SCL_PORT_X, MX_I2C_SCL_TRIS_X, MX_I2C_SCL_PIN_X); //Set SCL Low
^
Test(STM32F051C8T6).c:258:27: note: in expansion of macro 'portg'
#define MX_I2C_SCL_PORT_1 portg
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:65:26: note: in expansion of macro 'MX_I2C_SCL_PORT_1'
#define CAL_APD(a, b) a##b
^
C:
\Program Files (x86)\Flowcode 7\CAL\internals.c:66:28: note: in expansion of macro 'CAL_APD'
#define CAL_APPEND(a, b) CAL_APD(a, b)
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:214:28: note: in expansion of macro 'CAL_APPEND'
#define MX_I2C_SCL_PORT_X CAL_APPEND(MX_I2C_SCL_PORT_, MX_I2C_NUM)
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:328:22: note: in expansion of macro 'MX_I2C_SCL_PORT_X'
FC_CAL_Bit_Low_DDR(MX_I2C_SCL_PORT_X, MX_I2C_SCL_TRIS_X, MX_I2C_SCL_PIN_X); //Set SCL Low
^
In file included from C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.c:38:0,
from C:\Program Files (x86)\Flowcode 7\CAL\includes.c:47,
from Test(STM32F051C8T6).c:1463:
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c: In function 'FC_CAL_I2C_Master_TxByte_1':
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.h:86:15: error: 'GPIOG' undeclared (first use in this function)
#define portg GPIOG
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.h:136:68: note: in definition of macro 'FC_CAL_Bit_In_DDR'
#define FC_CAL_Bit_In_DDR(Port, Tris, Pin) (FC_CAL_Bit_In_DDR__x((Port), (Pin)))
^
Test(STM32F051C8T6).c:252:27: note: in expansion of macro 'portg'
#define MX_I2C_SDA_PORT_1 portg
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:65:26: note: in expansion of macro 'MX_I2C_SDA_PORT_1'
#define CAL_APD(a, b) a##b
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:66:28: note: in expansion of macro 'CAL_APD'
#define CAL_APPEND(a, b) CAL_APD(a, b)
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:211:28: note: in expansion of macro 'CAL_APPEND'
#define MX_I2C_SDA_PORT_X CAL_APPEND(MX_I2C_SDA_PORT_, MX_I2C_NUM)
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:355:23: note: in expansion of macro 'MX_I2C_SDA_PORT_X'
FC_CAL_Bit_In_DDR(MX_I2C_SDA_PORT_X, MX_I2C_SDA_TRIS_X, MX_I2C_SDA_PIN_X); //Set SDA High
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c: In function 'FC_CAL_I2C_Master_RxByte_1':
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.h:86:15: error: 'GPIOG' undeclared (first use in this function)
#define portg GPIOG
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_IO.h:136:68: note: in definition of macro 'FC_CAL_Bit_In_DDR'
#define FC_CAL_Bit_In_DDR(Port, Tris, Pin) (FC_CAL_Bit_In_DDR__x((Port), (Pin)))
^
Test(STM32F051C8T6).c:252:27: note: in expansion of macro 'portg'
#define MX_I2C_SDA_PORT_1 portg
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:65:26: note: in expansion of macro 'MX_I2C_SDA_PORT_1'
#define CAL_APD(a, b) a##b
^
C:\Program Files (x86)\Flowcode 7\CAL\internals.c:66:28: note: in expansion of macro 'CAL_APD'
#define CAL_APPEND(a, b) CAL_APD(a, b)
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:211:28: note: in expansion of macro 'CAL_APPEND'
#define MX_I2C_SDA_PORT_X CAL_APPEND(MX_I2C_SDA_PORT_, MX_I2C_NUM)
^
C:\Program Files (x86)\Flowcode 7\CAL\STARM\STARM_CAL_I2C.c:394:21: note: in expansion of macro 'MX_I2C_SDA_PORT_X'
FC_CAL_Bit_In_DDR(MX_I2C_SDA_PORT_X, MX_I2C_SDA_TRIS_X, MX_I2C_SDA_PIN_X); //Set SDA High
^
Error(s) in build

C:\Program Files (x86)\Flowcode 7\compilers\STARM\batch\stm32comp.bat notificado código de error 1

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 Delay I/O

Post by LeighM »

Could you please attache your Flowcode program?
Using "Upload attachment"

EDIT:
OK, I can see the issue in your posting,
from the test filename it looks like you are using STM32F051C8,
and you are using PORTG, but this device does not have a PORTG.
You will need to change the connection properties for the DS3231

volodymyr0604
Posts: 47
Joined: Sun Apr 05, 2009 2:39 pm
Been thanked: 1 time
Contact:

Re: STM32 Delay I/O

Post by volodymyr0604 »

Sorry, I was in a hurry and did not see the connection of the RTC (DS3231), PB6-SDA,PB7-SCL.
The ouput is good (125 kbits), after specifying the address for reading, there is no restart, reads 0xFF, the speed does not match, if you specify 400 kbit or 1 mbps, the real speed is 125 kbps.
The speed of the ports remained the same, the SPI2-HW speed was 12.5 Mbit, the delay between bytes was 10 microseconds.
My program for TFT-Touch without delay has a speed of 30 kbit, transmission and reception works well.
My program for I2C without delay has a speed of 50 kbit, transmission and reception works well.

STM32F051C8T6 ( 8MHz, HSI/2 * 12 = 48) I tried different HSE 8 MHz * 6 = 48, crystal HSE 26,6 MHz * 2=53.2.
The speed of the I / O ports is practically unchanged, and the delay between the bytes of the SPI port does not change, at different output speeds.

I do not know how to attach a file, tell me how to do it to send you.

Thanks for the quick answers.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 Delay I/O

Post by LeighM »

attach.jpg
attach.jpg (27.06 KiB) Viewed 18407 times

volodymyr0604
Posts: 47
Joined: Sun Apr 05, 2009 2:39 pm
Been thanked: 1 time
Contact:

Re: STM32 Delay I/O

Post by volodymyr0604 »

Hi LeighM. I send my file the Test.
RTC does not remember port connection
Thank you.
Attachments
RTC_STM32F051C8T6.png
(136.18 KiB) Downloaded 11815 times
SPI_STM32F051C8T6.png
(123.19 KiB) Downloaded 11815 times
TEST1_STM32F051C8T6.fcfx
(403.59 KiB) Downloaded 290 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 Delay I/O

Post by LeighM »

Hi

Thanks for your information. If I understand you correctly, your reported issues are:
1) SPI clock speed 12MHz
2) SPI delay between bytes of 10uS
3) RTC I2C speed is 125kbps even when faster selected
4) RTC does not remember port connections

My comments on these:
1) 12MHz SPI clock looks correct to me with a APB1 clock of 48MHz. For SPI1 you have the Prescaler property set to Fosc/16 and for SPI2 it is set to Fosc/4. The fastest setting is Fosc/2.
2) For the SPI peripheral code we interface to the ST HAL libraries. I have had a quick look and the 10uS delay does not look unreasonable to me for the amount of code that gets run.
3) and 4) There have been some recent updates to the RTC component regarding lost settings, I think this might explain both issues. Please could you replace the RTC component in your Flowcode components directory with the one attached, try it and see if that resolves the RTC issues.

Hope that helps and let me know if I have misunderstood or missed any issues.
Leigh
Attachments
RTC.fcpx
(9.77 KiB) Downloaded 300 times

volodymyr0604
Posts: 47
Joined: Sun Apr 05, 2009 2:39 pm
Been thanked: 1 time
Contact:

Re: STM32 Delay I/O

Post by volodymyr0604 »

Hi.
Thanks for the quick response. You have understood correctly.
STM32F051(52 MHz,SPI-12.5MHz) - TFT 2.4 320x240 clears the screen in 1.8 seconds. Atmega 2560 (16 MHz,SPI-8MHz)) clears the screen in 0.3-0.4 seconds.Cleaning program is the same.
Transmission over SPI is faster for TFT,Touch,SPI SRAM, Flash memory, SD. For this reason, I want delays of no more than 1μs when transferring data.
I have everything connected via SPI, and I need to transfer more data.

I checked the new RTC, Speed remained the same, does not remember the port.
Program is the same(10.004 bytes).I installed the NEW component of the RTC on May 14, 2017.
Attachments
TFT_STM32F051C8T6.png
(184.49 KiB) Downloaded 11798 times
NEW-RTC_STM32F051C8T6.png
(188.47 KiB) Downloaded 11799 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 Delay I/O

Post by LeighM »

To improve the transfer rate the SPI will need to send more than one byte per transaction.
So that means you writing some code or we add to the component.
It would be a good feature for us to add, but being busy it might be a while.
Next week I will see if I can come up with a quick workaround.

volodymyr0604
Posts: 47
Joined: Sun Apr 05, 2009 2:39 pm
Been thanked: 1 time
Contact:

Re: STM32 Delay I/O

Post by volodymyr0604 »

Hi LeighM.
Thank you. I'll wait.
I read the use of HAL library and DMA.

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 Delay I/O

Post by LeighM »

Hi,
I've written a macro, attached, that should enable you to send an array of bytes to the SPI channel.
Import this macro into your project and create two byte arrays (strings) to hold the send and receive data.
It compiles OK, but I have not had chance to test on hardware, please give it a try and let me know how it goes.
Leigh
Attachments
SPI_Transaction.fcm
(1.64 KiB) Downloaded 227 times

volodymyr0604
Posts: 47
Joined: Sun Apr 05, 2009 2:39 pm
Been thanked: 1 time
Contact:

Re: STM32 Delay I/O

Post by volodymyr0604 »

Hi LeighM.
Thank you.
I already tried through the string and through the Circular buffer, the same problem, the delay between the bytes is 10 us.
I watched STARM_CAL_Delay, there is a lines:
// With watchdog timer
#define FCI_DELAYBYTEWDT_S(count) Wdt_Delay_S((count))
#define FCI_DELAYBYTEWDT_MS(count) Wdt_Delay_Ms((count))
#define FCI_DELAYBYTEWDT_US(count) delay_us((count))
--------------------------------------
static inline void delay_10us(uint32_t __us10);
-------------------------------------
static inline void delay_10us(uint32_t __us10)
{
delay_us(__us10 * 10);
}
--------------------------------------
As I understand it, this is the minimum delay (10) mks.
Maybe this is the problem?
Attachments
Chip_FONT.jpg
Chip_FONT.jpg (103.68 KiB) Viewed 18212 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 Delay I/O

Post by LeighM »

The delay function only runs if you call it.
Even if you send a string, it will have been one byte at a time if you used the SPI component to send it.
Did you try the macro I sent you? This is designed to take the whole string and send it in one transaction.
Note that you still need to use the SPI component in your project and call its Initialise macro.
Then use the macro to send a buffer of data.

volodymyr0604
Posts: 47
Joined: Sun Apr 05, 2009 2:39 pm
Been thanked: 1 time
Contact:

Re: STM32 Delay I/O

Post by volodymyr0604 »

Hi LeingM.
Thank you.
I checked the program, speed 3MHz-after 6 bytes does not output, speed without delay.
Speed 12.5MHz-after 4 bytes does not output.
Attachments
TEST3_DSView(12.5MHz).png
(376.51 KiB) Downloaded 11608 times
TEST3_DSView.png
(308.86 KiB) Downloaded 11608 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 Delay I/O

Post by LeighM »

Hi
Could you try it again, but use allocated buffer space for the received data ...
buffer_variables.jpg
buffer_variables.jpg (18.61 KiB) Viewed 18147 times

volodymyr0604
Posts: 47
Joined: Sun Apr 05, 2009 2:39 pm
Been thanked: 1 time
Contact:

Re: STM32 Delay I/O

Post by volodymyr0604 »

Hi LeighM.
I checked.
At the beginning of the program, the CPU flushes if I connect the macro, after all the initialization the macro works (slightly changed).
It's unclear why there is still a delay in setting-0.
Attachments
TEST3_1_Clear_TFT.png
(236.02 KiB) Downloaded 11485 times
TEST3_FC_Clear.png
(180.1 KiB) Downloaded 11485 times
TEST3_SPI1.png
(354.88 KiB) Downloaded 11512 times

volodymyr0604
Posts: 47
Joined: Sun Apr 05, 2009 2:39 pm
Been thanked: 1 time
Contact:

Re: STM32 Delay I/O

Post by volodymyr0604 »

Hi LeighM.
Tried with DMA, does not work(slightly changed).
Attachments
SPI Send DMA.png
(87.38 KiB) Downloaded 11485 times

User avatar
LeighM
Matrix Staff
Posts: 2178
Joined: Tue Jan 17, 2012 10:07 am
Has thanked: 481 times
Been thanked: 699 times
Contact:

Re: STM32 Delay I/O

Post by LeighM »

The delay is for the same reason as before, it is the time the code takes to setup the transaction.
You only have 2 bytes in each transaction.
Try loading up a larger buffer with data before sending it in a single transaction.

volodymyr0604
Posts: 47
Joined: Sun Apr 05, 2009 2:39 pm
Been thanked: 1 time
Contact:

Re: STM32 Delay I/O

Post by volodymyr0604 »

With more bytes, the CPU is croaking, and there is nothing further.
Now some problems, the address of reading the font can not be calculated, reads from one address, the reading of the font chip is normal.
.char = 0х30
.font_Offset = 0х20
.num_bytes_letra = 0x20
.font_address = 0х8000
.Addr_Char = (((.char - .font_Offset) * .num_bytes_letra) + 4) + .font_address
.Addr_Char =(((0x30-0x20)*0x20)+4)+0x8000 = There must be an address = 0x8204, Reads start address = 0х8000
Before the modification read normally bytes of the font
Attachments
SPI2_RD_Font1.png
There must be an address = 0x8204
(109.59 KiB) Downloaded 11442 times
FC programm
FC programm
FC_Font_addr.jpg (52.86 KiB) Viewed 18013 times
SPI2_RD_Font0.png
Reads start address = 0х8000
(137.72 KiB) Downloaded 11442 times

volodymyr0604
Posts: 47
Joined: Sun Apr 05, 2009 2:39 pm
Been thanked: 1 time
Contact:

Re: STM32 Delay I/O

Post by volodymyr0604 »

Hi LeighM.
I saw that the simulation is proceeding normally, I tried it in a step-by-step mode,
after compilation problems arise when the program is running.
And there are problems with Flowcode v7.2.0.5
Hi Injector in the panel is, but in the console there.
With the simulation, in the step-by-step mode, the data in the console does not immediately appear.
Maybe this does not work properly with your macro SPI_Transaction.
Attachments
FC_Consolas.png
And there are problems with Flowcode v7.2.0.5
(65.38 KiB) Downloaded 11367 times
FC_Chip-Font.png
Compilation problems.
(113.52 KiB) Downloaded 11367 times

volodymyr0604
Posts: 47
Joined: Sun Apr 05, 2009 2:39 pm
Been thanked: 1 time
Contact:

Re: STM32 Delay I/O

Post by volodymyr0604 »

Hi LeighM.
Reinstalled FC, HI injector appeared in the console, I will try further,
disappeared Circular Buffer.
Still, there are problems, the compiler message window is cleaned immediately after compilation.
Attachments
Mensajes Compilador.png
(165.4 KiB) Downloaded 11363 times

Post Reply