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 /* mbed Microcontroller Library 00002 * Copyright (c) 2019 ARM Limited 00003 * SPDX-License-Identifier: Apache-2.0 00004 */ 00005 00006 #include "mbed.h" 00007 00008 Serial pc(USBTX, USBRX); 00009 PortOut sekmin(PortC,0xFFFF); 00010 PortOut st(PortB,0xFF); 00011 DigitalOut blink(PA_5); 00012 00013 00014 int sek=0, mins=59, stde=23; 00015 unsigned int t1,t2; 00016 00017 void TIM6isr() 00018 { 00019 blink=!blink; 00020 sek++; 00021 if (sek==60) 00022 { 00023 sek=0; 00024 mins++; 00025 if (mins==60) 00026 { 00027 mins=0; 00028 stde++; 00029 if (stde==24) 00030 { 00031 stde=0; 00032 } 00033 } 00034 } 00035 TIM6->SR=0; 00036 HAL_NVIC_ClearPendingIRQ(TIM6_IRQn); 00037 } 00038 00039 /* TIM6 init function */ 00040 static void tim6_Init(void) 00041 { 00042 RCC->APB1ENR|=0b10000; //Clock Enable 00043 TIM6->PSC=31999; //Prescaler 1ms 00044 TIM6->ARR=1000; //Autoreload 1s 00045 TIM6->DIER=1; //UIE = 1 (Update Interrupt Enable) 00046 TIM6->SR=0; //UIF =0 (Update Interrupt Flag) 00047 TIM6->CR1=1; //CEN=1 (Counter Enable) 00048 00049 NVIC_SetVector(TIM6_IRQn, (uint32_t)&TIM6isr); 00050 HAL_NVIC_EnableIRQ(TIM6_IRQn); 00051 } 00052 00053 void sendeZeit() 00054 { 00055 pc.printf("%d,%d,%d,%d,%d,%d", 00056 (unsigned int)sekmin%16, 00057 (unsigned int)(sekmin/16)%16, 00058 (unsigned int)(sekmin/256)%16, 00059 (unsigned int)(sekmin/4096)%16, 00060 (unsigned int) st%16, 00061 (unsigned int) st/16); 00062 } 00063 00064 int main() 00065 { 00066 volatile int sekalt=0; 00067 00068 tim6_Init(); 00069 00070 while (true) { 00071 //sekmin=sek; 00072 if (sekalt!=sek) 00073 { 00074 // sekmin=sek; 00075 sekalt=sek; 00076 t1=sek%10; 00077 t1=t1+((sek/10)<<4); 00078 t1=t1+((mins%10)<<8); 00079 t1=t1+((mins/10)<<12); 00080 t2=stde%10; 00081 t2=t2+((stde/10)<<4); 00082 sekmin=t1; 00083 st=t2; 00084 sendeZeit(); 00085 } 00086 } 00087 }
Generated on Sat Jul 16 2022 12:07:42 by
1.7.2