PwmOut doesn't work on Pokitto


#1

I was intending to start work on the next installment of the PEX tutorials which was supposed to be about PWM output (since the Pokitto doesn’t have true analogue output), but I’ve hit a snag.

It seems that the construction of an mbed::PwmOut object causes the Pokitto to lock up. I don’t know if it’s getting stuck in a loop or if the CPU is crashing somehow.

I’ve confirmed that it’s the construction of the PwmOut object that causes it.
I tried making the object global, which causes the Pokitto to lock up the moment it’s switched on.
I also tried making the object local by creating it after pokitto.begin() and that allows the Pokitto to go up to the headphone configuration screen and lock up after confirming a headphone volume. Notably the headphone screen stays displayed, implying that the screen is still drawing but the buffer isn’t being cleared.

When I say ‘lock up’, I mean only the main process freezes at the point of construction.
Interrupts still work so it’s still possible to put the Pokitto into CRP DISABLD mode and upload a new program.

I’m not sure if this is a fault with the PwmOut class or a conflict between PwmOut and the Pokitto library, but I would assume that PwmOut normally works on all mbed boards and that a code conflict is more likely.

(Despite not being sure I’ve categorised this under ‘bug reports’ because it’s a bug with something in the software chain, whether it’s the Pokitto side or the mbed side.)


Sample of global creation:

#include "Pokitto.h"

// The pokitto core library
Pokitto::Core pokitto;

// Create a 'PwmOut' object to represent the
// pwm output pin used to output a signal to the LED
// The object is set to use the EXT0 pin for output
PwmOut led = PwmOut(EXT0);

// The main function
int main()
{
	// Initialise the Pokitto
	pokitto.begin();

	// The main loop
	while (pokitto.isRunning())
	{
		// Update the Pokitto's state
		if (pokitto.update())
		{
		}
	}

	return 0;
}

Sample of local creation:

#include "Pokitto.h"

// The pokitto core library
Pokitto::Core pokitto;

// The main function
int main()
{
	// Initialise the Pokitto
	pokitto.begin();

	// Create a 'PwmOut' object to represent the
	// pwm output pin used to output a signal to the LED
	// The object is set to use the EXT0 pin for output
	PwmOut led = PwmOut(EXT0);

	// The main loop
	while (pokitto.isRunning())
	{
		// Update the Pokitto's state
		if (pokitto.update())
		{
		}
	}

	return 0;
}


#2

I know where the problem is. Please try disabling sound from project.

I will make a workaround. Its caused by too much sound routine optimization (i am bypassing the mbed library).


#3

It doesn’t lock up anymore in the local version
(I added some simple drawing code to check - a few coloured rectangles),
but it still locks up when initialising as a global variable and it’s still not outputting the signal correctly - the LED won’t light up.

Interestingly though, if I put the Pokitto into CRP DISABLD mode after disabling the sound then my PWM-driven LED lights up, but only after going into CRP DISABLD.


On the off-chance that you ask, I checked PROJ_ENABLE_SOUND == 0 with a static_assert to be sure that the settings were set properly and I made sure to clean and delete the bin before building to be extra sure.