preface
Because of my Bi sheshi supermarket cashier system, I learned a digital voice broadcasting module in December. Based on the needs of Bi sheshi, I will write a small digital voice broadcasting algorithm. If there are deficiencies, please comment and correct below. Novice Xiaobai can also ask questions if he doesn't understand. I will reply as soon as I have time to see it.
Tip: the following is the main content of this article. The following cases can be used for reference
1, What is MY2480?
2, Use steps
1. Import and storage
The code is as follows: as long as the serial port is used to send instructions, the module can perform relevant tasks
void voice_send_command(u8 command,u8 grama) { usart3_send_byte(0X7E); usart3_send_byte(0X03); usart3_send_byte(command); usart3_send_byte(grama); usart3_send_byte(0XEF); } 2.read in data
The code is as follows: take numerical operation. Here is only a small part. For details, please download the code below
a = strtod((char *)usart1_type.usart1_readBuf, NULL); //Character type to floating point data c = (a - (int)a) * 100; //Take decimal // printf("a=%.2f\r\n", a); while (i--) { if (((int)a) / ((int)pow(10, i)) % 10 > 0) // (int)a) cast data type. If you don't understand it here, practice it with the C language compiler { money[i] = i + 1; for (j = i; j >= 0; j--) { sound[j] = ((int)a) / ((int)pow(10, j)) % 10; // ((int)pow(10, j)) } //j=3 ﹐ 1000 ﹐ kilobits break; //j=2 ﹐ 100 ﹐ hundreds } //j=1 ﹐ 10 ﹐ tens } //j=0 # 10000 bits num_flag = money[i]-1; //Judge the number of digits. When assigning values here, it should be - 1, otherwise you will be judged by one more digit
Physical wiring diagram
Effect drawing of data verification
Printing the decimal point here or adding a delay will lead to a bug, so it will not be printed to the serial port assistant. The specific reason is not clear. If there is a great God, please give an idea and method verification
summary
This is my first blog. The original intention is for everyone to make progress and learn together. I came from Xiaobai's experience and understand the program with a little logic, but I can't understand it. I also wrote several notes here. I hope Xiaobai can understand and become stronger!
The great God understands it. If you have ideas, you can also point them out. You are willing to accept and learn!
Author: Mr'K (a pre engineer who loves embedded)
Baidu online disk: Please enter the extraction code for Baidu online disk
Extraction code: MrsK