ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
timer0_print_cpuid.c
Go to the documentation of this file.
1// Copyright 2021 IOsetting <iosetting(at)outlook.com>
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#include "fw_hal.h"
16
17static uint16_t counter = 0;
18
19
21{
22 return (*(unsigned char volatile __CODE *)(__CID_ADDR + offset));
23}
24
25INTERRUPT(Timer0_Routine, EXTI_VectTimer0)
26{
27 uint8_t i, j;
28 counter++;
29 if (counter == 1000)
30 {
31 i = 0;
32 counter = 0;
33 UART1_TxString("ADDR: 0x");
35 UART1_TxHex(__CID_ADDR & 0xFF);
36 UART1_TxString("\r\n");
37 UART1_TxString(" VER1 VER2\r\n");
38 UART1_TxString("VRTRIM 40M: ");
40 UART1_TxString("\r\n");
41 UART1_TxString("VRTRIM 24M: ");
43 UART1_TxString("\r\n");
44 UART1_TxString("VRTRIM 35M ??M: ");
46 UART1_TxString("\r\n");
47 UART1_TxString("VRTRIM 20M ??M: ");
49 UART1_TxString("\r\n");
50 UART1_TxString("ITRIM --- 45M: ");
52 UART1_TxString("\r\n");
53 UART1_TxString("ITRIM --- 40M: ");
55 UART1_TxString("\r\n");
56 UART1_TxString("ITRIM 36.864M: ");
58 UART1_TxString("\r\n");
59 UART1_TxString("ITRIM 35M: ");
61 UART1_TxString("\r\n");
62 UART1_TxString("ITRIM 33.1776M: ");
64 UART1_TxString("\r\n");
65 UART1_TxString("ITRIM 30M: ");
67 UART1_TxString("\r\n");
68 UART1_TxString("ITRIM 27M: ");
70 UART1_TxString("\r\n");
71 UART1_TxString("ITRIM 20M: ");
73 UART1_TxString("\r\n");
74 UART1_TxString("ITRIM 24M: ");
76 UART1_TxString("\r\n");
77 UART1_TxString("ITRIM 22.1184M: ");
79 UART1_TxString("\r\n");
80 UART1_TxString("32kHz PD FreQ: ");
83 UART1_TxString("\r\n");
84 UART1_TxString("1.19Vref: ");
87 UART1_TxString("\r\n");
88 UART1_TxString("\r\n");
89 UART1_TxString("MCUID: ");
90 for (j = 0; j < 7; j++)
91 {
93 UART1_TxChar(' ');
94 }
95 UART1_TxString("\r\n");
96 UART1_TxString("Current IRCBAND:");
97 UART1_TxHex(IRCBAND);
98 UART1_TxString(", VRTRIM:");
99 UART1_TxHex(VRTRIM);
100 UART1_TxString(", IRTRIM:");
101 UART1_TxHex(IRTRIM);
102 UART1_TxString(", LIRTRIM:");
103 UART1_TxHex(LIRTRIM);
104 UART1_TxString("\r\n\r\n");
105 }
106}
107
108void main(void)
109{
110 // Set system clock. Remove this line if system clock is already set by STC-ISP
111 SYS_SetClock();
112 // UART1 configuration: baud 115200 with Timer2, 1T mode, no interrupt
114 // Timer0 configuration: 16-bit auto-reload, interrupt enabled
120
121 while(1);
122}
#define __CID_ADDR
Definition: fw_cid_stc8h.h:21
#define EXTI_Timer0_SetIntPriority(__PRIORITY__)
Definition: fw_exti.h:214
@ EXTI_IntPriority_High
Definition: fw_exti.h:25
#define EXTI_Timer0_SetIntState(__STATE__)
Definition: fw_exti.h:116
#define EXTI_Global_SetIntState(__STATE__)
Definition: fw_exti.h:115
#define EXTI_VectTimer0
Definition: fw_exti.h:38
void SYS_SetClock(void)
Definition: fw_sys.c:40
@ TIM_TimerMode_16BitAuto
Definition: fw_tim.h:24
void TIM_Timer0_Config(HAL_State_t freq1t, TIM_TimerMode_t mode, uint16_t frequency)
Definition: fw_tim.c:38
#define TIM_Timer0_SetRunState(__STATE__)
Definition: fw_tim.h:35
unsigned short uint16_t
Definition: fw_types.h:19
@ HAL_State_ON
Definition: fw_types.h:71
unsigned char uint8_t
Definition: fw_types.h:18
void UART1_TxChar(char dat)
Definition: fw_uart.c:72
void UART1_TxString(uint8_t *str)
Definition: fw_uart.c:85
@ UART1_BaudSource_Timer2
Definition: fw_uart.h:34
void UART1_TxHex(uint8_t hex)
Definition: fw_uart.c:79
void UART1_Config8bitUart(UART1_BaudSource_t baudSource, HAL_State_t _1TMode, uint32_t baudrate)
Definition: fw_uart.c:56
uint8_t __XDATA i
INTERRUPT(Timer0_Routine, EXTI_VectTimer0)
void main(void)
uint8_t readCode(uint8_t offset)
static uint16_t counter