Administrator
|
This post was updated on .
I’m seeing an increased number of people having problems with their BlueSaab modules caused in particular by communications with RN52 Bluetooth module. While I’m trying to figure out the best way of getting everything to configure and work automagically, I’m putting together a set of instructions and a video on how to factory reset the RN52 module and upload all the settings that are essential for BlueSaab to work, so we all are on the same page with regards to RN52 settings.
In a true engineering fashion, I really suck at writing documentation, but hope these instructions and video will help you. So here it goes… Key assumptions: - You have an USB->FTDI cable. - There are three main parts of BlueSaab module: CAN chip, RN52 Bluetooth chip and ATMEGA328P-PU. - BlueSaab code asserts it uses comms over UART @ 9600bps to talk to RN52. Using any other baud rate on RN52 will result in lack of functionality of BlueSaab code. - By default (factory default setting) RN52 is configured to use comms @ 115200bps. - I’ve written some code to program RN52. You will need to get it from here. - Methods of code upload (Arduino IDE, Xcode, etc.), Terminal app choice or use of OS (Windows, OSX) may vary, but the overall procedure is the same. In this tutorial I'm going to use Xcode and Terminal apps running on OSX 10.11 "El Capitan". - All commands sent to RN52 Bluetooth module should be entered without quotes (“). - As you type in the commands in Terminal app, you won’t see any immediate output till you press the Enter key. Possible replies are “AOK” (everything is fine), “ERR” (error) or “?” (sorry, what was that again?). Procedure of re-setting and setting up RN52 again for use with BlueSaab code: 1. Connect BlueSaab module to your computer using USB->FTDI cable. 2. Open 'RN52-BT-PRG' code and make sure that BAUDRATE constant in 'RN52.h' file is set to 9600. 3. Upload the code to BlueSaab module. 4. Open Terminal app of your choice using baud rate @ 9600bps. You should see the following output: - RN52 programming mode - CMD 5. Enter “SF,1” command. This will instruct the RN52 to reset to factory defaults. 6. Disconnect the module from your computer. 7. Edit 'RN52.h' file and change the constant BAUDRATE to 115200. 8. Connect BlueSaab module back to the computer and upload the code. 9. Open Terminal app of your choice and make sure that you now use baud rate @ 115200bps. As seen on the video, my terminal app started @ 9600bps, hence no output. Had to fix it. 10. Enter “SU,01” command. This will instruct RN52 to switch the comms to 9600bps. 11. Disconnect the module from your computer. 12. Edit ‘RN52.h’ file and change the constant BAUDRATE to 9600. 13. Connect BlueSaab module back to the computer and upload the code. 14. Open Terminal app of your choice using baud rate @ 9600bps. You should see the following output: - RN52 programming mode - CMD 15. Enter “S-,<whatever>” command. This will set the modules ‘normalized’ name followed by last four symbols of the MAC address. This is not visible to the end user. 16. Enter “SN,<whatever>” command. This will set the modules ‘broadcast’ name. This is what you will see in the Bluetooth settings of your audio source (phone, tablet, etc.). 17. Enter “SC,200420” command. This will set ‘CoD’ (class of device) to “car audio”. 18. Enter “SS,0F” command. This will set the volume gain on the module to max (value 15). 19. Enter “S%,0084” command. This sets the following extended features to “ON”: - Discoverable on startup - Disable system tones 20. Enter “SD,06” command. Sets the discovery mask to A2DP and SPP protocols. 21. Enter “SK,06” command. Sets the connection mask to A2DP and SPP protocols. 22. Disconnect the module from your computer. 23. Connect BlueSaab module back to the computer and open Terminal app of your choice using baud rate @ 9600bps. You should see the following output: - RN52 programming mode - CMD 24. Enter “D” command. This will list all the current RN52 settings. Verify that they are the same as you programmed earlier. 25. Upload the latest version of BlueSaab code.
2001 9-5 SE V6; 2006 9-5 Wagon; iOS; BlueSaab version = "latest and greatest" :)
|
Administrator
|
Very nice, Karlis!!
NC, USA
|
Administrator
|
In reply to this post by Karlis
Another way of restoring RN52 to factory defaults is via hardware way. In this case you can skip the first six steps and proceed from step #7. There's a GPIO4 pin which has to be driven HIGH in a certain manner during power up of the module. If I'm not mistaken, starting v3.2 of BlueSaab modules, Seth introduced a dedicated jumper for this purpose.
According to RN52 datasheet: "GPIO4: Driving this pin high during bootup will put the module in Factory Reset mode. To reset the module to the factory defaults, this pin should be high on power-up and then toggle low, high, low, high with a 1 second wait between the transitions. During runtime, the module will enter voice command mode if this pin is driven low. Reserved. Not available for reconfiguring as a general purpose IO pin."
2001 9-5 SE V6; 2006 9-5 Wagon; iOS; BlueSaab version = "latest and greatest" :)
|
In reply to this post by Karlis
With step #4 it only shows:
RN52 programming mode it doesn't show - CMD And if I type SF,1 it doesn't show the AOK message. Any idea what could be wrong on my end?
9-5 Estate MY2004/Aero/Glacier Blue/AS2
|
I used one older version (without the last commit) and now it works with the 3.1 module :)
9-5 Estate MY2004/Aero/Glacier Blue/AS2
|
Administrator
|
it's been my experience that the easiest way to reset the module without losing communication (since we start at 9600, the reset changes the rn52 to 115200, and we have to change it back), is to short the GPIO7 pin to ground. Older pcbs don't have this jumper I made on v3.3, but GPIO7 is super easy to get to, and it's actually next to a GND pin already. Looking at the RN52, the bottom row of pins, you just short the left 2 pins together. I actually used a 1206 resistor, but just used one side of it; it bridges the 2 pins (without actually going through the resistor). Shorting this pin forces 9600, even during a factory reset, and the module wakes up with 9600 baud.
NC, USA
|
Administrator
|
In reply to this post by sloth
Please double check the terminal baudrate at which you are connecting to the module. It should be 9600. If worst comes to worst - try 115200, maybe RN52 has gone haywire (unlikely).
2001 9-5 SE V6; 2006 9-5 Wagon; iOS; BlueSaab version = "latest and greatest" :)
|
Administrator
|
Also, I just committed a change in RN52 programming code, that disables the PWREN pin. So it shouldn't cause any issues with PCB versions < 3.3.
2001 9-5 SE V6; 2006 9-5 Wagon; iOS; BlueSaab version = "latest and greatest" :)
|
This post was updated on .
Hi!
Is this step still necessary even when I got the latest commit from the master branch running on the module? The links supplied by this forum don't seem to work. This ( ;cid=1465151651709-609 ) gets added. thanks! |
Administrator
|
Yes, if you are running the latest software revision from Github, I would highly encourage you to match RN52 settings as well. The new Bluetooth handling code heavily relies on these settings being programmed on RN52.
For some reason forum appends embedded links with this ";cid=xxxxx". If you remove this portion of link, it should work.
2001 9-5 SE V6; 2006 9-5 Wagon; iOS; BlueSaab version = "latest and greatest" :)
|
In reply to this post by Karlis
Hi! I've just received my FDTI cable and successfully uploaded the latest SAAB-CDC code form GitHub.
Now I want to change the baudrate of the RN52. Using the latest commit from GitHub I have the same problem as hsl had. But he was using an older version of the RN52 program code, and i am not. I am not getting - CMD after - RN52 programming mode. Also no AOK after putting "SF,1" When I proceed I am unable to get a connection using 115200 as baudrate. The terminal says "sorry no TTY" and quits. The video shows that your BT1 en BT2 light are flashing, mine aren't. Only BT1 is flickering twice every second. BT2 stays off all the time. I am sorry for this very poor description because I have no programming experience and I am just following the tutorial and video. PCB version: 3.1 Hope you guys can help! |
Administrator
|
have you shorted the GPIO7 pin to ground? That will force the RN52 to 9600 baud, which is what you want anyway. See my prior post.
NC, USA
|
In reply to this post by Karlis
No, I am not really comfortable doing that. You need to do that when the module is powered on? I'd rather do it the software way.
|
Administrator
|
No, you just use solder/wire/whatevershort GPIO7 pin to ground. It's permanent. Then the software will work fine. I'm really not sure why you would be uncomfortable doing this one simple mod after having built the entire module...
NC, USA
|
Administrator
|
In reply to this post by joopworst
Ok, Karlis has informed me that you have a pre-built module. sorry about that.
Still, the mod is SUPER easy to do and will make the baud rate issue go away.
NC, USA
|
Administrator
|
In reply to this post by joopworst
Alright - first things first. Let's determine in what state the RN52 is. So you said you uploaded the latest RN52 code from Github. You didn't do any changes to BAUDRATE constant in the code before doing the upgrade, did you? If so, it is quite possible that RN52 is still set to 9600. So my suggestion would be to change BAUDRATE setting in the code to 9600, then upload it to the board and then open terminal at 9600. You should see CMD now.
2001 9-5 SE V6; 2006 9-5 Wagon; iOS; BlueSaab version = "latest and greatest" :)
|
In reply to this post by Karlis
I performed your guide till step #4. It opens the terminal and it says 9600 in de top bar. no CMD showing though. only programming mode.
PS; since you're online right now we could teamview... let me know |
This sounds slightly familiar…I may have had a similar problem. I was using minicom for the terminal connection, and I recall that I had to play with the handshaking parameters (rtscts, xonxoff) to get things to work properly at one point. I hope this helps…
|
Administrator
|
So joopworst's issue has been resolved. It took a bit of "persuasion" to get RN52 into talking at a proper bitrate. One thing we did differently is (on a Mac) - when opening serial port for comms with RN52, we added 8,N,1 settings at the end.
2001 9-5 SE V6; 2006 9-5 Wagon; iOS; BlueSaab version = "latest and greatest" :)
|
Is it possible too change baudrate if you don't have a FTDI cable ? I have the V3.1 module with mini USB stuck in 115200 baud :/
|
Free forum by Nabble | Edit this page |