Speech synthesis module based on 51 single chip microcomputer

Publisher:SparklingRiverLatest update time:2020-08-25 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

#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

    Program Screenshots

  • Circuit Diagram

    Circuit Diagram


Reference address:Speech synthesis module based on 51 single chip microcomputer

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

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号