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
00001 #include "mbed.h" 00002 00003 // Declare output LEDs 00004 DigitalOut ledgreen(PTD5); 00005 DigitalOut ledred(PTE29); 00006 00007 // Serial for debuggin purposes 00008 00009 void initialize_ticker(); 00010 00011 int main() { 00012 ledred = 1; 00013 ledgreen = 0; 00014 initialize_ticker(); 00015 while(1){ 00016 00017 } 00018 } 00019 00020 void flip() { 00021 //clear interrupt 00022 PIT->CHANNEL[1].TFLG |= PIT_TFLG_TIF_MASK; 00023 ledgreen = !ledgreen; 00024 ledred = !ledred; 00025 } 00026 00027 void initialize_ticker(){ 00028 //enable clock 00029 SIM->SCGC6 |= SIM_SCGC6_PIT_MASK; 00030 //set to zero to enable PIT 00031 PIT->MCR = 0x00; 00032 //clear interrup before enabling it 00033 PIT->CHANNEL[1].TFLG |= PIT_TFLG_TIF_MASK; 00034 PIT->CHANNEL[1].LDVAL = 0x00; //.04us 00035 //enable interrup 00036 PIT->CHANNEL[1].TCTRL |= PIT_TCTRL_TIE_MASK; 00037 //enable interrtup 00038 __enable_irq(); 00039 NVIC_SetVector(PIT_IRQn, (uint32_t)flip); 00040 NVIC_EnableIRQ(PIT_IRQn); 00041 //start timer 00042 PIT->CHANNEL[1].TCTRL |= PIT_TCTRL_TEN_MASK; 00043 }
Generated on Fri Jul 15 2022 02:36:47 by
1.7.2