ATY_LIB V2_102_230218
ATY_LIB for general devices or ALGO
 
Loading...
Searching...
No Matches
mem_read_chipid.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
22#include "fw_hal.h"
23
24uint8_t __XDATA i, buff[32] = {0};
25
26void PrintBuff(void)
27{
28 for (i = 0; i < 32; i++)
29 {
30 UART1_TxHex(*(buff + i));
31 if (i % 8 == 7) UART1_TxChar(0x20);
32 }
33 UART1_TxString("\r\n STC8H8K64U ");
34 UART1_TxString("\r\nCPUID: ");
35 for (i = 0; i < 7; i++)
36 {
37 UART1_TxHex(*(buff + i));
38 }
39 UART1_TxString("\r\nVref 1.19V: 0x");
40 UART1_TxHex(*(buff + i++));
41 UART1_TxHex(*(buff + i++));
42 UART1_TxString("\r\n32KHz: 0x");
43 UART1_TxHex(*(buff + i++));
44 UART1_TxHex(*(buff + i++));
45 UART1_TxString("\r\n22.1184MHz: 0x");
46 UART1_TxHex(*(buff + i++));
47 UART1_TxString("\r\n24MHz: 0x");
48 UART1_TxHex(*(buff + i++));
49 UART1_TxString("\r\n20MHz 27MHz: 0x");
50 UART1_TxHex(*(buff + i++));
51 UART1_TxString("\r\n27MHz 30MHz: 0x");
52 UART1_TxHex(*(buff + i++));
53 UART1_TxString("\r\n30MHz 33.1176MHz: 0x");
54 UART1_TxHex(*(buff + i++));
55 UART1_TxString("\r\n33.1776MHz 35MHz: 0x");
56 UART1_TxHex(*(buff + i++));
57 UART1_TxString("\r\n35MHz 36.864MHz: 0x");
58 UART1_TxHex(*(buff + i++));
59 UART1_TxString("\r\n36.864MHz 40MHz: 0x");
60 UART1_TxHex(*(buff + i++));
61 UART1_TxString("\r\n40MHz 44.2368MHz: 0x");
62 UART1_TxHex(*(buff + i++));
63 UART1_TxString("\r\n45MHz 48MHz: 0x");
64 UART1_TxHex(*(buff + i++));
65 UART1_TxString("\r\nVRTRIM 6MHz: 0x");
66 UART1_TxHex(*(buff + i++));
67 UART1_TxString("\r\nVRTRIM 10MHz: 0x");
68 UART1_TxHex(*(buff + i++));
69 UART1_TxString("\r\nVRTRIM 27MHz: 0x");
70 UART1_TxHex(*(buff + i++));
71 UART1_TxString("\r\nVRTRIM 44MHz: 0x");
72 UART1_TxHex(*(buff + i++));
73 UART1_TxString("\r\n00: 0x");
74 UART1_TxHex(*(buff + i++));
75 UART1_TxString("\r\n\r\n");
76 UART1_TxString("Current IRCBAND:");
77 UART1_TxHex(IRCBAND);
78 UART1_TxString(", VRTRIM:");
79 UART1_TxHex(VRTRIM);
80 UART1_TxString(", IRTRIM:");
81 UART1_TxHex(IRTRIM);
82 UART1_TxString(", LIRTRIM:");
83 UART1_TxHex(LIRTRIM);
84 UART1_TxString("\r\n\r\n");
85}
86
87void ItrimScan(uint8_t ircband, uint8_t vrtrim_limit, uint8_t irtrim_limit)
88{
89 uint8_t i = 0, j = 0;
90 while (i++ < vrtrim_limit)
91 {
92 j = 0;
93 while (j++ < irtrim_limit)
94 {
95 SYS_SetFOSC(ircband, i, j, 0);
96 SYS_Delay(10);
97 PrintBuff();
98 }
99 }
100}
101
102void main(void)
103{
104 SYS_SetClock();
105 // UART1 configuration: baud 115200 with Timer2, 1T mode, no interrupt
108 PrintBuff();
109
110 while(1)
111 {
116 //ItrimScan(__CONF_IRCBAND, 0xE0, 0xE0);
117 }
118}
void MEM_ReadChipID(uint8_t *buff)
void SYS_SetClock(void)
Definition: fw_sys.c:40
void SYS_Delay(uint16_t t)
Definition: fw_sys.c:65
#define SYS_SetFOSC(__IRCBAND__, __VRTRIM__, __IRTRIM__, __LIRTRIM__)
Definition: fw_sys.h:47
@ 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
void main(void)
uint8_t __XDATA buff[32]
uint8_t __XDATA i
void PrintBuff(void)
void ItrimScan(uint8_t ircband, uint8_t vrtrim_limit, uint8_t irtrim_limit)