Skip to content

examples/heartrate: use of rand.Intn appears to freeze the program on nrf51 #53

@knieriem

Description

@knieriem

In revision 3e2ce45 examples/heartrate got extended, i.a. by implementing a heart rate value that changes over time using rand.Intn.

It seems, though, that in order to run examples/heartrate after this change on a micro:bit,
I have to replace rand.Intn by some other code (e.g. a constant, or some increasing integer);
then I am able to see the "tick" messages on the serial line, and I'm able to receive the values on a smartphone.

With rand.Intn, on the other hand, the program somehow freezes, printing fatal error: .
GDB shows nrf51.cpu -- clearing lockup after double fault, but I don't know if that is related.
rand.Intn uses sync.Mutex, I don't know if this might be a source of the problem.

When I use rand.Intn in a normal program on micro:bit, without softdevice, it works.
So, for instance, a small program like

func main() {
	for {
		println("rand", rand.Intn(20))
		time.Sleep(time.Second)
	}
}

works on plain micro:bit, but doesn't work on -target microbit-s110v8 - at least for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingnrfNordic Semi SoftDevice

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions