Serial issue AT-09 Bluetooth 4.0 Module Transceiver BLE CC2540 CC2541 MLT-BT05 HM-10

tecnition_ted

New Member
Hi having a problem with baud rate when I change frequency from setfreq m16 back to setfreq m8 or setfreq mdefault.
If I use this code

Code:
setfreq m16                                                                     ;set clock from 8mhz to 16
init:    high C.4                                                                 ;prepare output
    pause 1000                                                                  ;wait 
main:    serout C.4, T2400, ("Value =", #b1,CR,LF)           ; send value at Baud 9600
    let b1 = b1 + 1                                                            ; add 1 to previous value
    pause 1000                                                                  ;wait 
    goto main                                                                    ; return to start of program

Then the bluetooth module works and transmits data

if I add this to the code then it messes everything up the above Baud rate is changed.

[code]
setfreq                                                                           ;set clock from 8mhz to 16
init:    high C.4                                                               ;prepare output
    pause 1000                                                                ;wait 
main:    serout C.4, T2400, ("Value =", #b1,CR,LF)         ; send value at Baud 9600
    let b1 = b1 + 1                                                          ; add 1 to previous value
    pause 1000                                                                ;wait 
    setfreq m8                                                                 ;return clock to 8mhz
    Pause 1000                                                                ;wait 
    goto main                                                                 ; return to start of program
 

tecnition_ted

New Member
Ok Ive seen it! the second setfreq m16 never gets re used as it is only used at the beginning of the code. silly mistake

Code:
setfreq  M16                                                                               ;set clock from 8mhz to 16
init:    high C.4                                                                           ;prepare output
pause 1000                                                                               ;wait
main:    serout C.4, T2400, ("Value =", #b1,CR,LF)                    ; send value at Baud 9600
let b1 = b1 + 1                                                                         ; add 1 to previous value
pause 1000                                                                               ;wait
setfreq M8                                                                               ;set clock from 8mhz to 16
    Pause 1000                                                                           ;wait
    setfreq                                                                                  ;set clock from 8mhz to 16
    goto main                                                                            ; return to start of program
 

hippy

Senior Member
setfreq m16
serout C.4, T2400, ("Value =", #b1,CR,LF) ; send value at Baud 9600
To send at 9600 baud you should ideally replace the T2400 with T9600_16.

The problem with the code which does not work, is that you change to SETFREQ M8 but do not change back to M16 before your next SEROUT.

Without that your second SEROUT sends at 4800 baud.

[Looks like you figured it out while I was posting]
 

tecnition_ted

New Member
Hi Hippy,
Do you still need to change the clock speed when using the T9600_16 command I ask as I did try this first but it wouldn't communicate with the Bluetooth module.
 

hippy

Senior Member
To use T9600_16 to give 9600 baud you need the clock speed to be M16.

But I am not now convinced you want a baud rate of 9600. It's not clear what PICAXE you are using but using T2400 at 16MHz doesn't necessarily give 9600 no matter what your code comment claims.
 

tecnition_ted

New Member
Hi Hippy this code works to output serial to an AX133 and the HC-09 Bluetooth module.
I am having issues with the HC-09 in that I can only receive serial using a serial android app I cannot pair the module and the manufacture is no help.
it could just be a fluke its working

[Bluetooth part code]

#Picaxe 08M2

setfreq m16
high C.0
pause 1000
serout c.0,T2400,("Time left ",#w6,CR,LF)
serout c.0,T2400,("Charge ",#SOC,"%",CR,LF)
serout c.0,T2400,("Volt ",#Volt,CR,LF)
setfreq mdefault
Pause 30
serout c.4,N2400,(254,128) ; move to start of first line
serout c.4,N2400,("Time left ",#w6)
serout c.4,N2400,(254,192) ; move to start of second line
serout c.4,N2400,("Charge ",#SOC,"%")
goto main
 

hippy

Senior Member
Hi Hippy this code works to output serial to an AX133 and the HC-09 Bluetooth module.
I am having issues with the HC-09 in that I can only receive serial using a serial android app I cannot pair the module and the manufacture is no help.
If it's working, then it's working, so I am not exactly sure what the question is, where any problem lies. If receiving with an Android app one would assume it has paired.

On an 08M2 it should be a simple swap of "T2400" to "T9600_16"; both named constants have the same value.
 
Top