Bluetooth & wifi freeze issue

Hi, currently im having a problem with bluetooth and wifi code that cause the device to freeze.
the base code taken from this page:

the problem is that sometimes when i trigger the bluetooth to input the wrong password and reset the imp. and the imp will freeze without running the code (which is to turn OFF the LED (normally ON))
this is not always happen, 3 out of 10 the device will freeze.
is there any way to solve this or any workaround?

my device is imp004m

and this is my code:
#require “bt_firmware.lib.nut:1.0.0”
server.setsendtimeoutpolicy(RETURN_ON_ERROR, WAIT_TIL_SENT, 5);

//led setup
led_pin ← hardware.pinP

led_pin.configure(DIGITAL_OUT,0) // the program will not turn off the LED after the bluetooth triggered

//bt setup
bt_uart ← hardware.uartFGJH;
bt_lpo_in ← hardware.pinE;
bt_reg_on ← hardware.pinJ;

// Boot up Bluetooth: ground LPO_IN and set BT_REG_ON to High
bt_lpo_in.configure(DIGITAL_OUT, 0);
bt_reg_on.configure(DIGITAL_OUT, 1);

bt ← null;
bt =, BT_FIRMWARE.CYW_43438);

//gatt setup
connection ← null;

local service = {};
// WiFi Credential Refresh Service
service.chars ← [];

local chara = {};

// Set dummy characteristic
chara = {};
chara.write ← function(conn, v) {
imp.setwificonfiguration(“correct ssid”,“incorrect pw”)

imp.onidle(function() {


server.log(“Serving GATT…”);

bt.onconnect(function(conn) {
connection = conn;
server.log(conn.address() + " connected");

conn.onclose(function() {
    server.log(connection.address() + " disconnected");

//advertise setup
local unit_model = “TESTXX_”
unit_model = unit_model + hardware.getdeviceid()
unit_model = “\x09”+unit_model
local len=unit_model.len()

bt.startadvertise(len.tochar()+unit_model, 100, 100);

Can you explain your LED wiring? pinP will be tristate (not driven high) before the configure(DIGITAL_OUT,0) runs which sets the line low.

This will not provide enough current to light an LED, unless there’s an external switch with a pull-up?

Hi Hugo,

the pinP is pulled up externally, then the imp will sink it to turn it off.

the LED only as the indicator if the program running or not. after turning off the LED it will broadcast the bluetooth ads. and if the led not turning off the bluetooth also will not broadcast the ads. so i assume that the code do not start.

Can you see the BLE advertising, even if the LED is lit?

no, the ble not advertising.

problem update:
just found out that there is a power supply problem with my pcb.
the freeze problem occur when i use this settings

then fixed when i change to this one

Which regulators are you using? 24v->5v is a big drop (lots of heat) - even 12v->3.3v is probably not an ideal thing to do with an LDO.

buck converter fp6150 for the top configuration

after further testing i also try to replace the buck converter with linear regulator
12v → 5v linear regulator → 3.3v ->imp004m
this configuration also work fine. so i think the buck converter is the main problem here. still not sure though.

With any buck converter, the PCB layout is really critical - was the buck driving 3v3 directly? (it sounds like this is what you had, even if it was buck from 5v->3v3).

The FP6150 datasheet has no traces of (eg) load transient response, so the claim of “fast transient response” is a bit hollow. Generally any DCDC datasheet will have scope captures showing how the part behaves with load step, etc.

Using DCDC for the big drop (12/24->5) and then an LDO for 5->3v3 lets the LDO tidy up any noise, and should help here - but you would also be ok using a better quality DCDC to feed 3v3 directly.

For example, we use the TPS62130 in some of our designs (max 17v input) and this is very clean and small - the higher switching frequency really helps.

This topic was automatically closed after 60 days. New replies are no longer allowed.