Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- ShaolinPoutine
- Date:
- 2017-03-04
- Revision:
- 1:8b93b2102ac5
- Parent:
- 0:529210499c6d
- Child:
- 2:1665cd4c922c
File content as of revision 1:8b93b2102ac5:
#include "mbed.h"
#define clock_max 96000000
DigitalOut myled(LED1);
extern "C" void TIMER2_IRQHandler (void)
{
if((LPC_TIM2->IR & 0x01) == 0x01) // if MR0 interrupt, proceed
{
LPC_TIM2->IR |= 1 << 0; // Clear MR0 interrupt flag
}
}
void init_clk()
{
LPC_PINCON->PINSEL0 |=3<<12; //P0.6 = MAT2.0 // p8
LPC_SC->PCLKSEL1 |=1<<12; //pclk timer2 = cclk
LPC_SC->PCONP |=1<<22; //timer2 power on
LPC_TIM2->MR0 = clock_max / 2; // 1 sec period
LPC_TIM2->MCR = 3; //interrupt and reset control
//3 = Interrupt & reset timer2 on match
//1 = Interrupt only, no reset of timer0
LPC_TIM2->EMR =3<<4; //EMC0 = 11 (Toogle)
NVIC_EnableIRQ(TIMER2_IRQn); //enable timer2 interrupt
LPC_TIM2->TCR = 1; //enable Timer2
}
int mainRaph()
{
init_clk();
}
void tick()
{
myled = !myled;
}
int main() {
Ticker ticker;
ticker.attach(&tick, 0.5);
}