dhgdh
Dependencies: MAX44000 PWM_Tone_Library nexpaq_mdk
Fork of LED_Demo by
main.cpp
00001 #include "mbed.h" 00002 00003 extern "C" { 00004 volatile uint32_t msTicks; 00005 00006 void SysTick_Handler(void) { 00007 msTicks++; 00008 } 00009 00010 void Delay(uint32_t dlyTicks) { 00011 uint32_t curTicks; 00012 00013 curTicks = msTicks; 00014 while ((msTicks - curTicks) < dlyTicks); 00015 } 00016 } 00017 00018 int main() { 00019 SysTick_Config(SystemCoreClock / 1000); 00020 00021 SIM->SCGC6 |= SIM_SCGC6_PIT_MASK; // Clock PIT 00022 PIT->MCR = 0; // Enable PIT 00023 00024 // Timer 1 00025 PIT->CHANNEL[1].LDVAL = 0xFFFFFFFF; 00026 PIT->CHANNEL[1].TCTRL = 0x0; // Disable Interrupts 00027 PIT->CHANNEL[1].TCTRL |= PIT_TCTRL_CHN_MASK; // Chain to timer 0 00028 PIT->CHANNEL[1].TCTRL |= PIT_TCTRL_TEN_MASK; // Start timer 1 00029 00030 // Timer 2 00031 PIT->CHANNEL[0].LDVAL = 0xFFFFFFFF; 00032 PIT->CHANNEL[0].TCTRL = PIT_TCTRL_TEN_MASK; // Start timer 0, disable interrupts 00033 00034 DigitalOut led(LED_BLUE); 00035 while (true) { 00036 Delay(1000); 00037 led = !led; 00038 00039 uint64_t ticks = (uint64_t)PIT->LTMR64H << 32; 00040 ticks |= (uint64_t)PIT->LTMR64L; 00041 printf("ticks: 0x%x%x\n", (uint32_t)(ticks>>32), (uint32_t)(ticks & 0xFFFFFFFF)); 00042 00043 ticks = (~ticks) / 24; 00044 uint32_t us = (uint32_t)(0xFFFFFFFF & ticks); 00045 00046 printf("us : 0x%x\n", us); 00047 } 00048 }
Generated on Tue Jul 12 2022 11:01:53 by
1.7.2
