#include "main.h"
bit bSysHalfSec;
u8 TimeWaitCnt = 0;
u8 code PrevFile[] = {0xAA, 0x05,0x00, 0xAF};/*This array instruction can be directly generated by the host computer and copied over */
u8 code NextFile[] = {0xAA, 0x06, 0x00, 0xB0};
u8 code Path[] = {0xAA, 0x08, 0x10, 0x02, 0x2F, 0xB9, 0xE3, 0xB8, 0xE6, 0x2A, 0x2F, 0xD0, 0xA1, 0xC3, 0xD7, 0x2A, 0x4D, 0x50, 0x33, 0x8B, }; // flash / advertisement*/ Xiaomi*MP3
/***************************************************************************************
This program is the C51 version of the MP3 serial port module test program. The test chip uses STC12C5A32S2, external crystal oscillator, 11.0592MHZ
Serial port setting: 9600
**************************************************************************************/
u8 UartData = 0xff;
/*****************************************************************************
Function name: Timer0Init
Functional description: Timer initialization timing 2 milliseconds @ 11.0592MHz
Input parameters: void
Output parameters: None
return value :
Call functions :
Called function:
Change history:
1. Date: March 26, 2013
Author : Blueice
Modifications: New generation function
*****************************************************************************/
void Timer0Init ( void )
{
AUXR |= 0x80; /*Timer clock 1T mode */
TMOD &= 0xF0; /*Set timer mode */
TMOD |= 0x01; /*Set timer mode */
TL0 = 0x9A; /*Set the initial timing value */
TH0 = 0xA9; /*Set the initial timing value */
TF0 = 0; /*Clear TF0 flag */
TR0 = 1; /*Timer 0 starts timing */
ET0 = 1;
}
/*****************************************************************************
Function name: SysInit
Functional description: System initialization
Input parameters: void
Output parameters: None
return value :
Call functions :
Called function:
Change history:
1. Date: March 24, 2013
Author : Blueice
Modifications: New generation function
*****************************************************************************/
void SysInit ( void )
{
Timer0Init();
UartInit();
EA = 1;/*Open the general interrupt */
}
/*****************************************************************************
Function name: Delay1us
Function description: 1 microsecond delay function
Input parameter: int T
Output parameters: None
return value :
Call functions :
Called function:
Change history:
1. Date: February 19, 2016
Author: wskblueice
Modifications: New generation function
*****************************************************************************/
void Delay1us ( int T )
{
T = T - 70;
do
{
;
}
while ( T-- );
}
#define sda P01 /*One-line serial port sending pin */
/*****************************************************************************
Function name: SendData
Function description: One-line serial port sending function
Input parameter: u16 N
Output parameters: None
return value :
Call functions :
Called function:
Change history:
1. Date: August 17, 2014
Author: wskblueice
Modifications: New generation function
*****************************************************************************/
void SendData ( u8 addr )
{
u8 i;
EA = 0; /* Turn off interrupts when sending to prevent interrupts from affecting timing */
sda = 1;/*Start pulling */
Delay1us ( 1000 );
sda = 0;/*Start boot code*/
Delay1us ( 2200 );/*The delay here must be at least greater than 2ms, and the delay of this parameter is 310ms */
for ( i = 0; i < 8; i++ ) /*8 bits of data in total */
{
sda = 1;
if ( addr & 0x01 ) /*3:1 indicates data bit 1, each bit is represented by two pulses */
{
Delay1us ( 500 );
sda = 0;
Delay1us ( 210 );
}
else /*1: 3 represents data bit 0, each bit is represented by two pulses */
{
Delay1us ( 210 );
sda = 0;
Delay1us ( 500 );
}
addr >>= 1;
}
sda = 1;
EA = 1;
}
/*****************************************************************************
Function name: UartSendData
Function description: Two-wire serial port sends commands
Input parameter: u8 *Buff
Output parameters: None
return value :
Call functions :
Called function:
Change history:
1. Date: May 1, 2016
Author: wskblueice
Modifications: New generation function
*****************************************************************************/
void UartSendData ( u8 *Buff, u8 Len )
{
u8 i;
for ( i = 0 ; i < Len ; i++ )
{
UartPutByte ( Buff[i] );
}
}
/*****************************************************************************
Function name: main
Functional description: System main loop
Input parameters: void
Output parameters: None
return value :
Call functions :
Called function:
Change history:
1. Date: February 21, 2013
Author : Blueice
Modifications: New generation function
*****************************************************************************/
void main ( void )
{
SysInit();
P0M0 |= BIT ( 0 ) | BIT ( 1 );
UartSendData ( Path, 20 );
while ( 1 )
{
if ( TimeWaitCnt == 4 ) /*The next song command will be automatically sent every two seconds */
{
TimeWaitCnt = 0;
SendData ( 0x15 );//next file
//UartSendData ( NextFile,4 );
}
}
}
/*****************************************************************************
Function name: tm0_isr
Function description: Timer interrupt
Input parameters: None
Output parameters: None
return value :
Call functions :
Called function:
Change history:
1. Date: March 26, 2013
Author : Blueice
Modifications: New generation function
*****************************************************************************/
void Timer0_isr() interrupt 1
{
static u8 TimeCnt;
TL0 = 0x9A; /*Set the initial timing value */
TH0 = 0xA9; /*Set the initial timing value */
TimeCnt++;
if ( ( TimeCnt % 5 ) == 0 )
{
}
if ( ( TimeCnt % 250 ) == 0 )
{
TimeCnt = 0;
bSysHalfSec = !bSysHalfSec;
P00 = !P00;
TimeWaitCnt++;
}
}
Program Screenshots
Circuit Diagram
Previous article:Intelligent control system of temperature and humidity in vegetable greenhouse based on 51 single chip microcomputer
Next article:MCU + MAX6675 thermocouple (thermopile) intelligent body temperature detection system
- 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
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- What will happen if the servo motor inertia is insufficient?
- How to select parameters for servo motor inertia size
- The difference between the servo motor moment of inertia and the load moment of inertia
- How to calculate the inertia of servo motor and reducer
- What is the difference between a servo press and a normal press?
- 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
- EEWORLD University Hall----Robotics Visual Control Matlab Simulation
- Open source a graphical building block programming controller board PCB and host computer source code
- Complete set of Chinese FPGA introductory and advanced tutorials (1)
- Design of infrared remote control signal receiving module based on FPGA
- Can STM32G431 perform "bit-band operation"?
- Big news - TI launches the smallest data converter with high integration and high performance!
- Timer
- Teensy 4.0 Development Board
- 2812 Debugging Problem Set
- Dear experienced people, do you draw a flowchart before writing code?