• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

DFplayer, an mp3 player. UART and how that works?

SimonTHK

Member
Hello smart people

I am trying to make an mp3 player work, called dfplayer FN-M16P. This is the datasheet: http://www.flyrontech.com/uploadfile/download/20184121510393726.pdf

So I am not working with electronics and programming so often sadly. I have a hard time making it work. It seems that I should send information to it via UART, so I does this with a PSOC microprocessor (like arduino).

But when the datasheet tells me that Play is all these, do I have to send them once after the other as hexidecimals? How do the receiving end RX need it?
Play= 7E FF 06 0D 00 00 00 FE EE EF

Play alone are only 0x0D but it seems that I still might need to send the whole lot of hexidecimals each time. I am confused sadly. I miss something. I just lack some knowledge that is difficult to obtain and I hate to buy arduino and just use libraries!

Thansk in advance on helping me with the advanced project.

Best regards Simon
 

Nigel Goodwin

Super Moderator
Most Helpful Member
You don't need to 'buy' an Arduino - just download the library and see what it does!. Then copy the parts of the library you want.

Arduino libraries are a great resource for other processors, and far easier and faster than using the datasheet.
 

SimonTHK

Member
You don't need to 'buy' an Arduino - just download the library and see what it does!. Then copy the parts of the library you want.

Arduino libraries are a great resource for other processors, and far easier and faster than using the datasheet.
But what can you learn if you link to libraries? It probably am ok, since almost anyone uses it. Ohh well. Thx
 

Nigel Goodwin

Super Moderator
Most Helpful Member
But what can you learn if you link to libraries? It probably am ok, since almost anyone uses it. Ohh well. Thx
I never suggested you linked to the library, just examine the code it uses, and write your own - generally it's a matter of writing C code to do what the C++ in the library does.

What do you learn if you ask for advice? - the datasheet is all you really need.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
I've just managed to find a bit of old PIC code from when I was playing with a DFPlayer module.

C:
void HSerout(unsigned char ch)
    {
    while(!TXIF);                    // Wait for module to finish
    TXREG = ch;                        // ready to send
    }   

while(1)                    // Loop forever
{
        LCD_clr();
        HSerout(0x7E);
        HSerout(0xFF);
        HSerout(0x06);
        HSerout(0x03);
        HSerout(0x00);
        HSerout(0x00);
        HSerout(0x01);                // play track 1
        HSerout(0xFE);
        HSerout(0xF7);
        HSerout(0xEF);
        LCD_goto(1,0);                // line 1.
        LCD_printC(" Sent cmd 1");
        delayMs(10000);                // wait for 10 seconds

        LCD_clr();
        HSerout(0x7E);
        HSerout(0xFF);
        HSerout(0x06);
        HSerout(0x03);
        HSerout(0x00);
        HSerout(0x00);
        HSerout(0x02);                // play track 2
        HSerout(0xFE);
        HSerout(0xF6);
        HSerout(0xEF);
        LCD_goto(1,0);                // line 1.
        LCD_printC(" Sent cmd 2");
        delayMs(10000);                // wait for 10 seconds

        LCD_clr();
        HSerout(0x7E);
        HSerout(0xFF);
        HSerout(0x06);
        HSerout(0x03);
        HSerout(0x00);
        HSerout(0x00);
        HSerout(0x03);                // play track 3
        HSerout(0xFE);
        HSerout(0xF5);
        HSerout(0xEF);
        LCD_goto(1,0);                // line 1.
        LCD_printC(" Sent cmd 3");
        delayMs(10000);                // wait for 10 seconds

        LCD_clr();
        HSerout(0x7E);
        HSerout(0xFF);
        HSerout(0x06);
        HSerout(0x01);
        HSerout(0x00);
        HSerout(0x00);
        HSerout(0x00);                // play next track
        HSerout(0xFE);
        HSerout(0xFA);
        HSerout(0xEF);
        LCD_goto(1,0);                // line 1.
        LCD_printC(" Sent cmd Next");
        delayMs(10000);                // wait for 10 seconds
}
This short demo code just plays 10 seconds of various tracks in turn.
 

SimonTHK

Member
I've just managed to find a bit of old PIC code from when I was playing with a DFPlayer module.

C:
void HSerout(unsigned char ch)
    {
    while(!TXIF);                    // Wait for module to finish
    TXREG = ch;                        // ready to send
    }  

while(1)                    // Loop forever
{
        LCD_clr();
        HSerout(0x7E);
        HSerout(0xFF);
        HSerout(0x06);
        HSerout(0x03);
        HSerout(0x00);
        HSerout(0x00);
        HSerout(0x01);                // play track 1
        HSerout(0xFE);
        HSerout(0xF7);
        HSerout(0xEF);
        LCD_goto(1,0);                // line 1.
        LCD_printC(" Sent cmd 1");
        delayMs(10000);                // wait for 10 seconds

        LCD_clr();
        HSerout(0x7E);
        HSerout(0xFF);
        HSerout(0x06);
        HSerout(0x03);
        HSerout(0x00);
        HSerout(0x00);
        HSerout(0x02);                // play track 2
        HSerout(0xFE);
        HSerout(0xF6);
        HSerout(0xEF);
        LCD_goto(1,0);                // line 1.
        LCD_printC(" Sent cmd 2");
        delayMs(10000);                // wait for 10 seconds

        LCD_clr();
        HSerout(0x7E);
        HSerout(0xFF);
        HSerout(0x06);
        HSerout(0x03);
        HSerout(0x00);
        HSerout(0x00);
        HSerout(0x03);                // play track 3
        HSerout(0xFE);
        HSerout(0xF5);
        HSerout(0xEF);
        LCD_goto(1,0);                // line 1.
        LCD_printC(" Sent cmd 3");
        delayMs(10000);                // wait for 10 seconds

        LCD_clr();
        HSerout(0x7E);
        HSerout(0xFF);
        HSerout(0x06);
        HSerout(0x01);
        HSerout(0x00);
        HSerout(0x00);
        HSerout(0x00);                // play next track
        HSerout(0xFE);
        HSerout(0xFA);
        HSerout(0xEF);
        LCD_goto(1,0);                // line 1.
        LCD_printC(" Sent cmd Next");
        delayMs(10000);                // wait for 10 seconds
}
This short demo code just plays 10 seconds of various tracks in turn.
Thank you very much. I will look into this. I would say does this quite the similar way, but sometimes 1 thing has been misunderstood. So this is great for me thanks.
Ill get back with an update.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
Thank you very much. I will look into this. I would say does this quite the similar way, but sometimes 1 thing has been misunderstood. So this is great for me thanks.
Ill get back with an update.
I suspect I was probably thinking the same as you - and that simple code was a quick test to see what happened.
 

SimonTHK

Member
I suspect I was probably thinking the same as you - and that simple code was a quick test to see what happened.
And your did work? Do you have any idea on how you did put the MP3 files? Since there are many ways to do it apparently, for this player.
Thanks
 

SimonTHK

Member
I've just managed to find a bit of old PIC code from when I was playing with a DFPlayer module.

C:
void HSerout(unsigned char ch)
    {
    while(!TXIF);                    // Wait for module to finish
    TXREG = ch;                        // ready to send
    }  

while(1)                    // Loop forever
{
        LCD_clr();
        HSerout(0x7E);
        HSerout(0xFF);
        HSerout(0x06);
        HSerout(0x03);
        HSerout(0x00);
        HSerout(0x00);
        HSerout(0x01);                // play track 1
        HSerout(0xFE);
        HSerout(0xF7);
        HSerout(0xEF);
        LCD_goto(1,0);                // line 1.
        LCD_printC(" Sent cmd 1");
        delayMs(10000);                // wait for 10 seconds

        LCD_clr();
        HSerout(0x7E);
        HSerout(0xFF);
        HSerout(0x06);
        HSerout(0x03);
        HSerout(0x00);
        HSerout(0x00);
        HSerout(0x02);                // play track 2
        HSerout(0xFE);
        HSerout(0xF6);
        HSerout(0xEF);
        LCD_goto(1,0);                // line 1.
        LCD_printC(" Sent cmd 2");
        delayMs(10000);                // wait for 10 seconds

        LCD_clr();
        HSerout(0x7E);
        HSerout(0xFF);
        HSerout(0x06);
        HSerout(0x03);
        HSerout(0x00);
        HSerout(0x00);
        HSerout(0x03);                // play track 3
        HSerout(0xFE);
        HSerout(0xF5);
        HSerout(0xEF);
        LCD_goto(1,0);                // line 1.
        LCD_printC(" Sent cmd 3");
        delayMs(10000);                // wait for 10 seconds

        LCD_clr();
        HSerout(0x7E);
        HSerout(0xFF);
        HSerout(0x06);
        HSerout(0x01);
        HSerout(0x00);
        HSerout(0x00);
        HSerout(0x00);                // play next track
        HSerout(0xFE);
        HSerout(0xFA);
        HSerout(0xEF);
        LCD_goto(1,0);                // line 1.
        LCD_printC(" Sent cmd Next");
        delayMs(10000);                // wait for 10 seconds
}
This short demo code just plays 10 seconds of various tracks in turn.
It works. IT WORKS! I cannot quite say why it havnt worked before. It is quite simple, but sometimes brains turn off.




char test1=0x7E;
char test2=0xFF;
char test3=0x06;
char test4=0x03;
char test5=0x00;
char test6=0x00;
char test7=0x01;
char test8=0xFE;
char test9=0xF7;
char test10=0xEF;


UART_PutChar(test1);
UART_PutChar(test2);
UART_PutChar(test3);
UART_PutChar(test4);
UART_PutChar(test5);
UART_PutChar(test6);
UART_PutChar(test7);
UART_PutChar(test8);
UART_PutChar(test9);
UART_PutChar(test10);

Thanks alot.
 

Latest threads

EE World Online Articles

Loading
Top