2013-10-01から1ヶ月間の記事一覧

MRT.cpp

#include "MRT.h" MRT::MRT(int channel) { LPC_SYSCON->SYSAHBCLKCTRL |= (1<<10); // enable MRT LPC_SYSCON->PRESETCTRL |= (1<<7); // reset MRT _ch = &LPC_MRT->Channel[channel]; _ch->CTRL |= (1<<1); // one-shot } void MRT::write(uint32_t inter…

MRT.h

#pragma once #include "LPC8xx.h" #define IDLE 0 #define RUNNING 1 class MRT { public: MRT(int channel); /** write down counter * @param interval start count */ void write(uint32_t interval); /** read down counter */ uint32_t read(); int st…

Multi-Rate Timer (MRT)

#include "mbed.h" DigitalOut led1(LED1); extern "C" void MRT_IRQHandler() { if (LPC_MRT->Channel[3].STAT & 1) { led1 = !led1; LPC_MRT->Channel[3].STAT |= 1; // clear interrupt } } int main() { LPC_SYSCON->SYSAHBCLKCTRL |= 1<<10; // enable …