Design and Implementation of a learning-type universal infrared remote control device based on STM32 (3), stm32 infrared remote control

Source: Internet
Author: User

Design and Implementation of a learning-type universal infrared remote control device based on STM32 (3), stm32 infrared remote control
3.1 Infrared Pulse Width storage and FLASH read/writeBased on different STM32 models, the FLASH capacity ranges from 16 KB to kb. The FLASH module consists of the primary memory, information block, and FLASH memory interface register. For module organization, see section 2.3.3 embedded flash memory in STM32 Chinese reference manual. The primary storage is used to store code and data constants. For large-capacity products, it is divided into 256 pages, 2 K bytes per page; for small-and medium-capacity products, 1 K per page. The Startup Program code of the information block is used to store the Startup Program that comes with ST for serial download. The user selects bytes to configure write protection and read protection. The interface register of the flash memory is the control mechanism of the entire flash memory module. It controls the read and write operations of the flash memory. FLASH can be directly addressable in a general address space. Any 32-bit data read operation can Access FLASH content and obtain the corresponding data. The fastest access speed of FLASH is less than or equal to 24 MHz. If the CPU frequency exceeds 24 MHz, the wait time must be added. For the 72 MHz clock speed, the FLASH wait period must be set to 2. Programming and erasure of FLASH. FLASH programming of STM32 is operated by the FPEC module. After the system is reset, The FPEC module will be protected and cannot be written. The relevant registers can be operated only after the FPEC module is enabled to remove the write protection from writing a specific sequence to the FLASH_KEYR register. Note: For STM32 FLASH programming, you must write 16-bit data each time, and the FLASH of the write address must be wiped out. Otherwise, the write is invalid. Write a specified number of data at the specified address, as shown in the flowchart: the program code is as follows: See the attachment to test whether the read/write data is correct using the hardware simulation function. In Debug mode, the Data Writing Function FLASH_WriteData () and the Data Reading function FLASH_ReadData () are executed in one step. The data written and read are shown in:3.2 learning buttons implemented by interrupt modeThe program that learns to press the key is implemented with External Interrupt disconnection 2. The Code is as follows: see the attachment.Modulation and transmission of 3.3 infrared signalsSince learning is a complete replication of the infrared pulse, you only need to extract the infrared data in FLASH and send it to the carrier. The flowchart is shown in:The program code is as follows:

/*************************************** * ***************************** Function Name: sendPort_Init (void) * Function: Infrared sending port control initialization * parameter: * Description: void * Return: void *************************************** * ****************************/void SendPort_Init (void) {GPIO_InitTypeDef GPIO_InitStructure;/* enable pd port clock */RCC_APB2PeriphClockCmd (RCC_APB2Periph_GPIOC, ENABLE);/* enable pd port configuration */GPIO_Init Structure. GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3; // LED0 --> PF6 ~~~ Configure the PF10 port with export = Taobao; GPIO_Init (GPIOC, & GPIO_InitStructure); GPIO_SetBits (GPIOC, GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2); // PD0 ~~~ PD2 outputs high GPIO_ResetBits (GPIOD, GPIO_Pin_3); // note !!!!!!!!!!!!} /*************************************** ** -- Keycode 52 received by the oscilloscope: 0101 0010 -- MCU received key code 4A: 0100 1010 -- sent key code 4A: 0100 1010 -- Verification Platform: Changhong TV, MCU verification passed: the TV can receive ************************************* * ***/service. ODPS .aliyun.com sendCode [200] = {0 }; void IR_SendData (u32 SendAddr) {u8 I; // service.com sendCode [200] = {0}; // ---------- verified. // for (I = 0; I <199; I ++) {// sendCode [I] = PulseTab [I]; //} // ---------- FLASH_ReadData (SendAddr, sendCode, 200) has been verified );/ /Retrieve data from the corresponding FLASH Address for (I = 0; I <100; I ++) {if (sendCode [2 * I]! = 0) & (sendCode [2 * I + 1]! = 0) {IR_SEND = 0; delay_us (sendCode [2 * I]); IR_SEND = 1; delay_us (sendCode [2 * I + 1]);} // IR_SEND = 0; // * the following two sentences are important; otherwise, an error occurs !!! * // Delay_us (555); IR_SEND = 1 ;}


Shows the simulation: 3.4 TFT Display ModuleTFT is short for Thin Film Transistor (Thin Film field effect Transistor). Each pixel on the LCD is driven by a Thin Film field effect Transistor integrated in the back. Therefore, this type of display features fast speed, high brightness, high contrast, and higher resolution than other types of LCD display. Shows the driver sequence of TFT liquid crystal: 3.5 entire systemFor example:
For the complete program of the entire system, see the attachment (to reduce the file, some files generated during compilation are deleted, so the project needs to be re-compiled)

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.