Because I am engaged in automotive CAN bus and multimedia decoding boxes, I often need to decode some simple CAN data. The hardware IO required is not much, just CAN+UART, so in order to save costs, I have also spent a lot of thought recently.
Until recently, I discovered STM32F042, which is said to be the smallest package chip with CAN.
STM32F042----Cortex-M0 core. The chip was launched in early 2014 and is known as the cheapest MCU with CAN bus....
After checking the manual carefully, I found that it is suitable for my project and the price is cheap, between RMB 4-6, and the smallest package is TSSOP20. It is tailor-made for small automotive products.
Without further ado, let's get started and build the minimum system first. The CAN transceiver TJA1050+STM32F042+7533 is the simplest. No crystal oscillator is needed for the time being. Although a crystal oscillator is still needed when the CAN baud rate is relatively high, a crystal oscillator costs a lot of RMB.
The most troublesome thing came next, because I was used to using IAR for development, and the program source codes I had accumulated were all from UCOSII, and the open source codes on the Internet were all from KEIL MDK. This was embarrassing...
But there is no other way. In order to save costs, I have to spend more time.
Two weeks later, everything was basically adjusted and the code architecture was migrated OK. Now we can finally migrate all the 103 codes to F042.
There are a few things to note:
1. Library function differences: F042 has modified many library functions, so you need to pay attention to the differences;
2. The CAN of F042 is different from that of 103, and you need to refer to the register definition. For high-speed baud rates such as 500K and 800K, an external crystal oscillator is required;
3. USART1 cannot be used because it is multiplexed with USART1/CAN/USB and is occupied by CAN;
4. The configuration file of F042 is not standardized. Many register definitions can only be found in F072, and the configuration file of F072 cannot be fully used;
5. The *it.c file of F042 is not standardized. In fact, the STM32F0 series is the same. The library function version is low, and the interrupt function file is not standardized, resulting in confusion in many function definitions;
6. Clock safety CSS is not mentioned at all. Although it can be found in various materials, almost no one uses it, and no one pays attention to the importance of CSS.
7. The power consumption of F042 is much smaller. Under the same clock 8MHZ, the current of F042 is only 4mA, while 103 reaches more than 9mA;
8. USART1 of F042 is an enhanced serial port that supports LIN master-slave mode, while UART2 is a common serial port that cannot be used in LIN master mode;
9. The nominal FLASH capacity of P042F4 is 16K, but the actual capacity is 32K. The F042F6 is really only 32K. I don't understand why.
10. It does a good job in low power consumption and is much more convenient than the F1 series.
Finally, I hope that F042 will be like 103, with cheaper price and better quality.
-------------------------------------------------------------
20180330 New questions:
Because this chip is used to make both CAN interface and LIN interface, I found that I could not completely transplant the LIN function library of the F1XX series. Because the function library of the F0XX series lacks many LIN-related functions compared to the F1XX, for example, there is a function Send_Break() which is very necessary for LIN communication, but I could not find the function definition at all. For this reason, I spent a lot of time studying how to implement the SendBreak function, but I still couldn't find it after more than a month. Finally, I spent money on Taobao to find a great person to help me solve it.
Some problems seem simple, but they are not the case when you actually make the product.
As the result of honest labor, every line of code is the result of many people's hard work and even painful lessons. Some ancestral codes may look messy but they are real iron rice bowls. The personal value of each programmer depends on these codes. Therefore, please respect the labor of others and cherish your own labor!
Previous article:Using STM32F103 for CAN transceiver communication
Next article:STM32 CAN bus experimental experience
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- The CC3200 LaunchPad crashed before I even got it warm?
- TMS320F28377S Study Notes 3 Building a fully portable CCS9.3 project
- Recruiting part-time lecturers in motor control related majors
- It is recommended to merge the ATMEL and PIC microcontroller sections
- TI TMS320C6678 Evaluation Module
- IoT wireless communication data transmission module: multi-host gateway working mode, understand it in one article
- [RT-Thread reading notes]——The definition of threads and the implementation of thread switching
- How to read and write attributes through the characteristic uuid in sdk!
- [Runhe Neptune Review] Five PWM
- How to use the wireless transceiver module