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

Status
Not open for further replies.

SimonTHK

Member
Hello smart people

I am trying to make an mp3 player work, called dfplayer FN-M16P. This is the datasheet: **broken link removed**

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
 
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.
 
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
 
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.
 
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.
 
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.
 
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
 
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.
 
One tip I give is if the noise levels arn't an issue don't bother with the checksums.

This is why I got a buspirate. Absolutely fantastic bit of kit and if something isn't working as expected you can play around with most comms standards without having to program anything up first!
 
There is also a mute pin on the amp IC that by default is grounded via a 0R resistor. Remove the latter and connect this to the busy signal pin to get rid of the switching noise when you initiate playback!
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…