Stm8s and stm32f IO port Output Rate Test

Source: Internet
Author: User

When I checked the stm32 data today, I was not very familiar with the output speed of 2 m 10 M 50 m, and there was an unexpected situation when I transplanted the arf2496k program to the stm32.

1. The data received by the 8s end as the receiving end and the sending end is normal.

2. the sender (8s) and the receiver (stm32) are also normal.

3. the sender (stm32) and receiver (ipv8) receive error data. The data is the same each time, but it is wrong.

Therefore, we will consider whether the stm32 I/O output speed is too fast. Today we will test it with an oscilloscope.

Many people on the Internet say that the I/O output of stm32 is configured to 2 MHz, 10 MHz, and 50 MHz, which is not the so-called output speed, but the flip speed.

The test oscilloscope is rigol ds1062ca, the probe is 10x, and channel 2 is captured.

Hardware: stm32f107 master, using the Shenzhou IV Development Board. In addition, the 8s controller is used, and the 8s core board is used.

Software: There are two types of software: library functions and non-library functions.

I. Use Database functions for output:

Int main () {systeminit (); // select the initialization system clock source, such as PLL, which is a library function, use the external crystal oscillator system to work with the 72 MHz # If 1 // test the I/O flip speed. The database function is about 2 MB and the 8 minit_pd11 () is directly operated on the register; // while (1) {gpio_setbits (gpiod, gpio_pd11); gpio_resetbits (gpiod, gpio_pd11) ;}# endif} void init_pd11 () {gpio_inittypedef gpio; // enable rcc_apb2periphclockcmd (rcc_apb2periph_gpiod, enable) and gpio for the peripheral clock of the PD port corresponding to the LED. gpio_pin = gpio_pin_11; gpio. gpio_speed = gpio_speed_2mhz; gpio. gpio_mode = gpio_mode_out_pp; // push and pull the output gpio_init (gpiod, & gpio );}

The oscilloscope waveform is shown below:

This waveform is used no matter how much gpio_speed is initially measured. That is to say, the output speed is just like this (2.25 MHz). It has nothing to do with the so-called 2 m, 10 m, 50 m.

The rising time is longer than the falling time.

2. directly operate registers

Only the code in the while (1) loop is modified as follows:

while(1){               GPIOD->BSRR=GPIO_Pin_11;               GPIOD->BRR=GPIO_Pin_11;}

The oscilloscope waveform is as follows:

According to the test, the output of 2 m 10 M 50 m is the waveform, but the speed is significantly increased by 3.5 times. This shows that the library function is inefficient. According to the manual, the flip speed is up to 18 MHz. I can only test the 8 MHz speed here.

Similarly, the increase time is longer than the decrease time.

Ipv8s Testing

In this test, some content is added. After Dividing 8 s into 4, the test is not divided into 8 s. Use an internal 16 MHz RC oscillator.

In the first case, the 4 MHz clock speed is tested.

1. Use the library function with the following code:

Main () {clk_ckdivr = idle; // fhsi = 16/4 = 4 MHz divides the main clock into gpio_init (gpiob, gpio_pin_1, timeout); While (1) {gpio_writehigh (gpiob, gpio_pin_1 ); gpio_writelow (gpiob, gpio_pin_1 );}}

The oscilloscope waveform is as follows:

The gap between the rising time and the falling time is not obvious here.

Ii. Operation register control output

The code is changed as follows:

While (1) {gpiob-> ODR | = gpio_pin_1; // In fact, this is the code of the library function, but it eliminates the need to call the function process gpiob-> ODR & = ~ Gpio_pin_1 ;}

The oscilloscope waveform is as follows:

Here we can clearly see the time difference between the rise and the fall, and the speed is also 8 times faster. In fact, these times are only spent on function call and return.

In the second case, the 16 MHz clock speed is tested.

The I/O speed of the library functions will not be tested here. Except for function calls, the internal code is consistent.

Directly operate the register control output. The oscilloscope waveform is as follows:

It is awesome, and it can reach 3.2 MHz.

Summary:

The output speed in stm32 is not the I/O flip speed. The test speed is only 8 MHz.

Library functions of stm32 are inefficient.

In the past, when both the receiver and the sending end adopted S, the communication was normal when the frequency was divided into 4 MHz. If the frequency of the sending end was not divided into 16 MHz, the phenomenon is the same as that in stm32.

When normal communication is possible, the I/O port speed is 95.8 kHz. At that time, no direct operation register method was used. It is found that the I/O speed reaches 3.2 MHz at the 16 MHz clock speed of ipv8s. As the sending end of stm32, the minimum speed of the natural I/O port is 2.2 MHz, this is probably because the speed is too fast, and the speed of arf2496k cannot keep up. As for why, it is not capable of further exploration.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.