Video demonstration address:
http://v.youku.com/v_show/id_XMTUyMzQwMjg4.html
The following are the detailed procedures:
/*****Program Author : ZhengWen(ClimberWin) *****/
/*****E_mail : cooldianzi@163.com *****/
/********************************************************************/
/*****File Function : IR Soft Recode(SAA3010) *****/
/*****Compile Date : 2009/2/4 *****/
/*****Edition Info : V1.0 *****/ /
*****Amend Date : *****/
/*****************************************************************/
/************Infrared software decoding, remote control model, SAA3310 chip************/
/***********************2009.2.4******************************/
/***********Can infrared decoding LCD display****************/
#include
#include "intrins.h "
#include "SAA3010_Recode.h"
#include "LCD12864.H"
#include
#include
#include
#include
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
sbit speaker=P2^1;
uchar LCD_IR_da
void Delay1ms(unsigned int count);
void Key_Beep(void);
void Delay_Beep(unsigned int count1);
void init_rs232(void);
/***************************1 second delay subroutine start***************************/
void Delay1ms(unsigned int count)
{
unsigned int i,j;
for(i=0;i
}
/***************************1 second delay subroutine end***************************/
/**********************Key sound************************/
void Key_Beep(void)
{ uchar i;
for (i=0;i<250;i++)
{ speaker=1;
Delay_Beep(30);
speaker=0;
Delay_Beep(30);
}
speaker=1;
}
/****************************************************** */
/***************************Buzzer delay subroutine start**********************/
void Delay_Beep(unsigned int count)
{
unsigned int i,j;
for(i=0;i
}
/***************************Buzzer delay subroutine end************************/
/* Serial communication initialization settings*/
void init_rs232(void)
{
AUXR=74; //Set the baud rate to 12 times of ordinary 51, and allow AD interrupt
SCON=0x50;
PCON=0x00;
TH1=0xFA; //Baud rate 115200 22.1184MHZ (F4 4800 FA 9600 FDH 9600)*12
TL1=0XFA;
TMOD=0X20;
TR1=1;
}
void main(void)
{
uchar key_co
uchar key_co
uchar key_co
Delay1ms(1000);
init_rs232();
TI=1;
printf("STC12C5410AD learning board infrared remote control decoding\n");
printf("ClimberWin 2009.2.4\n\n");
Delay1ms(5000);
LCD_INIT();
Delay1ms(1000);
LCD_LOCAL(1,1,"STC MCU Learning Board");
LCD_LOCAL(2,1,"MCU:STC12C5410AD");
LCD_LOCAL(4,1,"Date:2009.2.4 ");
LCD_LOCAL(3,1,"By ClimberWin ");
/********************************************/
Delay1ms(50000);
LCD_LOCAL(1,1,"Infrared remote control test interface");
LCD_LOCAL(2,1,"Remote control chip:SAA3010");
LCD_LOCAL(3,1,"Test result: ");
LCD_LOCAL(4,1," ");
printf("Infrared remote control test interface\n");
//Delay100us(8); // Actually 760uS
Key_Beep();
IR_Input = 1; //Pull the signal line high first, waiting for receiving infrared signalwhile
(1)
{
LCD_IR_data
LCD_IR_data
LCD_IR_data
if(!IR_Input) SAA3010_Recode();
if(SAA3010_CODE
{Key_Beep();
SBUF=SAA3010_CODE
portkey_code_b
=
key_code_g
LCD_IR_data
LCD_IR_da
LCD_IR_da
LCD_LOCAL(4,1,LCD_IR_da
SAA3010_CO
SAA3010_CO
SAA3010_CO
SAA3010_CO
}
else
{SAA3010_CO
}
}
LCD12864.H is as follows:
/*****Program Author : ZhengWen(ClimberWin) *****/
/*****E_mail : cooldianzi@163.com *****/
/****************************************************************/
/*****File Function : LCD12864 Display Module *****/
/*****Compile Date : 2009/1/28 *****/
/*****Edition Info : V1.0 *****/
/*****Amend Date : *****/
/*********************************************************************/
#ifndef __LCD12864__
#define __LCD12864__
#include
#define uchar unsigned char
#define uint unsigned int
#define ulong unsigned long
sbit LCD_CS = P1^7; //Chip select high level is valid when single-chip LCD is used, high level rs can be fixed
sbit LCD_SID = P1^6; //data r/w
sbit LCD_SCLK = P1^5; //clock e
/************************LCD12864******************************/
void LCD_SEND(uchar date);
void LCD_SCOM(bit st,uchar date);
void LCD_DELAY(void);
void LCD_INIT(void);
void LCD_write(uchar *p);
void LCD_LOCAL(uchar x,uchar y,uchar *p);
void LCD_cblank(uchar x,uchar y);
void LCD_count(long s,uchar x1,uchar y1,uchar x,uchar y,uchar *p);
void DELAYLCD(uchar t);
/********* ************************************************/
/**** ************************lcd12864****************************** ***********/
void DELAYLCD(uchar t)
{
while(--t);
}
void LCD_SEND(uchar date)
{
uchar i;
LCD_SCLK=0;
for(i=0;i<8;i++)
{
LCD_SID=date&0x80;
LCD_SCLK=1;
LCD_SCLK=0;
date<<=1;
}
}
void LCD_SCOM( bit st,uchar date)
{
uchar st_temp,hdate,ldate;
if(st)
st_temp=0xfa;
else st_temp=0xf8;
hdate=date&0xf0;
ldate=date&0x0f;
ldate <<= 4;
LCD_CS = 1;
LCD_SEND(st_temp);
LCD_SEND(hdate);
LCD_SEND(ldate);
LCD_CS = 0;
DELAYLCD(38);
}
void LCD_DELAY(void)
{ uchar s;
s=10;
while(--s)
DELAYLCD(250);
}
void LCD_INIT(void)
{
LCD_SCOM(0,0x30);
LCD_DELAY();
LCD_SCOM(0,0x0c);
LCD_DELAY();
LCD_SCOM(0,0x01); //Clear the screen and reset the DDRAM address counter to zero
LCD_DELAY();
}
void LCD_write(uchar *p)
{
while(*p)
{
LCD_SCOM(1,*p);
p++;
}
}
void LCD_LOCAL(uchar x,uchar y,uchar *p) //lcd string (x,y) write !
{
switch (x)
{
case 1:LCD_SCOM(0,0x7f+y); LCD_write(p);break;
case 2:LCD_SCOM(0,0x8f+y); LCD_write(p);break;
case 3:LCD_SCOM( 0,0x87+y); LCD_write(p);break;
case 4:LCD_SCOM(0,0x97+y); LCD_write(p);break;
default :LCD_SCOM(0,0x7f+y); LCD_write(p);
}
}
void LCD_cblank(uchar x,uchar y)
{
switch (x)
{
case 1:LCD_SCOM(0,0x7f+y); LCD_SCOM(0,0x0d);break;
case 2:LCD_SCOM(0,0x8f+y); LCD_SCOM(0,0x0d);break;
case 3:LCD_SCOM(0, 0x87+y); LCD_SCOM(0,0x0d);break;
case 4:LCD_SCOM(0,0x97+y); LCD_SCOM(0,0x0d);break;
default :LCD_SCOM(0,0x7f+y); LCD_SCOM(0, 0x0d);
}
}
/****************************************************** *************************/
/****************************************************** ****************************/
#endif
SAA3010_Rncode.H is as follows:
/*****Program Author : ZhengWen(ClimberWin) *****/
/*****E_mail : cooldianzi@163.com *****/
/********************************************************************/
/*****File Function : SAA3010 IR_Input soft recode *****/
/*****Compile Date : 2009/2/4 *****/
/*****Edition Info : V1.0 *****/
/*****Amend Date : *****/
/*****************************************************************/
/***************Software decoding of infrared remote control SAA3010*******************/
#ifndef __SAA3010_Rncode__
#define __SAA3010_Rncode__
#define uchar unsigned char
#include
sbit IR_Input=P3^4;
uchar SAA3010_CODE
void SAA3010_Recode(void);
void Delay100us(uchar i);
/*************SAA3010 decoding program**************/
void SAA3010_Recode(void)
{
unsigned char i, j;
bit FBIT;
// IR_Input changes from high to low, skip the first sampling
for (i=0; i<4; i++)
{
SAA3010_CO
}
/*--------------------------------------
Manchester code:
input binary code Manchester code
0 01
1 10
********************************************/
// Set as the second sampling, sampling time interval 800uS
Delay100us(8);
if (!IR_Input)
{
// Because the start bit of SAA3010 is 1
SAA3010_CO
SAA3010_CO
// Start the second bit and sample once
Delay100us(8);
if (IR_Input)
{ // The sample is 1
SAA3010_CO
FBIT = 1;
}
else
{ // The sample is 0
FBIT = 0;
}
if (FBIT)
{ // If the first sample is 1
while (IR_Input);
}
else
{
while (!IR_Input);
}
// Second sampling
Delay100us(8);
//----------------------------------------------------------------------------
// Sampling control bit
// One sampling
Delay100us(8);
if (IR_Input)
{
SAA3010_CO
FBIT = 1;
}
else
{
FBIT = 0;
}
if (FBIT)
{
while (IR_Input);
}
else
{
while (!IR_Input); // Wait for IR_Input to rise
}
// Second sampling
Delay100us(8);
//----------------------------------------------------------------------------------
// Collect system code (5 bits)
for (j=0; j<5; j++)
{
// First sampling
Delay100us(8);
if (IR_Input)
{
SAA3010_CO
FBIT = 1;
}
else
{
FBIT = 0;
}
if (FBIT)
{
while (IR_Input);
}
else
{
while (!IR_Input);
}
// Second sampling
Delay100us(8);
SAA3010_CO
}
//------------------------------------------------ --------------------------
// Collect data code (6 bits)
for (j=0; j<6; j++)
{
// One sampling
Delay100us(8);
if (IR_Input)
{
SAA3010_CODE
FBIT = 1;
}
else
{
FBIT = 0;
}
if (FBIT)
{
while (IR_Input);
}
else
{
while (!IR_Input);
}
// Second sampling
Delay100us(8);
SAA3010_CO
}
//-----------------------------------------------------------------------------
}
else
{ // It is jitter
for (i=0; i<4; i++)
{
SAA3010_CO
}
return;
}
SAA3010_CO
}
/************760us delay program************************/
void Delay100us(uchar i)
{
uchar j;
while(i<50)//50
{
for(j=0;j<50;j++)
{ _nop_();}
i++;
}
}
/****************************************************** *****/
#endif
Previous article:STC12C5410AD learning board --- serial communication
Next article:STM8S103 Unique ID Reader
- 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
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Good information on clock division
- Let’s practice together in 2021 + a great year!
- [Project Outsourcing] FPGA-based RAID card design
- How to use trap and varbind in lwip2.1.2
- str91 p6.6 p6.7 port always freezes when configuring uart0
- Effects of ESR and ESL in Decoupling Applications
- The new computer I bought can't be turned on, please help
- Solution to the failure of IAR programming MSP430
- MicroPython sets up a separate factory reset code file
- Display community logo on three-color E-Ink Gizmo