Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
12 years, 8 months ago.
FRDM-KL25Z board with USBDevice-USBKEYBOARD Freezes when using ticker
Does anyone have an idea why any time the ticker triggers it freezes when I am using the USBKeyboard.h?
Example
#include "mbed.h"
#include "MMA8451Q.h"
#include "USBKeyboard.h"
#define D_SDA PTE0
#define D_SCL PTE1
#define D_BAUDRATE 9600
#define MMA8451_I2C_ADDRESS (0x1d<<1)
USBKeyboard keyboard;
I2C i2c(D_SDA, D_SCL);
MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
Serial pc(USBTX, USBRX); // tx, rx
Ticker sleepTimer;
DigitalOut redLed(LED_RED);
DigitalOut grnLed(LED_GREEN);
DigitalOut bluLed(LED_BLUE);
void goToSleep()
{
//>do some stuff<
}
int main()
{
redLed = 1;
grnLed = 1;
bluLed = 1;
pc.baud(D_BAUDRATE);
i2c.frequency(400000);
MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
sleepTimer.attach(&goToSleep, 20);
while(1) {
// >insert rest of code here<
}
}