Unique ID는 시리즈마다 다른 위치에 있습니다. 선언되지 않았다면 Referance Manual 에서 주소를 확인하고 사용하여야 합니다.
/*===============stm32l496xx.h에 선언된 부분 ==================*/
#define PACKAGE_BASE ((uint32_t)0x1FFF7500U)
#define UID_BASE ((uint32_t)0x1FFF7590U)
#define FLASHSIZE_BASE ((uint32_t)0x1FFF75E0U)
/* Debug MCU registers base address */
#define DBGMCU_BASE ((uint32_t)0xE0042000U)
#define DBGMCU ((DBGMCU_TypeDef *) DBGMCU_BASE)
/*===============stm32l496xx.h에 선언된 부분 ==================*/
/*
Bits 31:16 REV_ID[15:0] Revision identifier
This field indicates the revision of the device.
For STM32L47x/L48x devices
0x1000: Rev 1
0x1001: Rev 2
0x1003: Rev 3
0x1007: Rev 4
For STM32L49x/L4Ax devices
0x1000: Rev A
0x2000: Rev B
Bits 15:12 Reserved, must be kept at reset value.
Bits 11:0 DEV_ID[11:0]: Device identifier
The device ID is:
0x461 for STM32L49x/L4Ax devices
0x415 for STM32L47x/L48x devices.
*/
#define Get_Device() (*(uint16_t *) (DBGMCU) & 0xFFFF)
#define Get_Revision() ((*(uint32_t *) (DBGMCU)&0xFFFF0000) >> 16)
#define Get_Package() ((*(uint16_t *) (PACKAGE_BASE)) & 0xFFFF)
#define Get_FlashSize() (*(uint16_t *) (FLASHSIZE_BASE) & 0xFFFF)
#define Get_Unique8(x) ((x >= 0 && x < 12) ? (*(uint8_t *) (UID_BASE + (x))) : 0)
#define Get_Unique16(x) ((x >= 0 && x < 6) ? (*(uint16_t *) (UID_BASE + 2 * (x))) : 0)
#define Get_Unique32(x) ((x >= 0 && x < 3) ? (*(uint32_t *) (UID_BASE + 4 * (x))) : 0)
UART1_printf("Package : %X\r\n", Get_Package());
UART1_printf("FlashSize : %XKB\r\n", Get_FlashSize());
UART1_printf("Get_Revision : %X\r\n", Get_Revision());
UART1_printf("Get_Unique32 : %08X", Get_Unique32(0));
UART1_printf(":%08X", Get_Unique32(1));
UART1_printf(":%08X\r\n", Get_Unique32(2));
UART1_printf("Get_Unique16 : %04X", Get_Unique16(0));
UART1_printf(":%04X", Get_Unique16(1));
UART1_printf(":%04X", Get_Unique16(2));
UART1_printf(":%04X", Get_Unique16(3));
UART1_printf(":%04X", Get_Unique16(4));
UART1_printf(":%04X\r\n", Get_Unique16(5));
UART1_printf("Get_Unique8 : %02X", Get_Unique8(0));
UART1_printf(":%02X", Get_Unique8(1));
UART1_printf(":%02X", Get_Unique8(2));
UART1_printf(":%02X", Get_Unique8(3));
UART1_printf(":%02X", Get_Unique8(4));
UART1_printf(":%02X", Get_Unique8(5));
UART1_printf(":%02X", Get_Unique8(6));
UART1_printf(":%02X", Get_Unique8(7));
UART1_printf(":%02X", Get_Unique8(8));
UART1_printf(":%02X", Get_Unique8(9));
UART1_printf(":%02X", Get_Unique8(10));
UART1_printf(":%02X\r\n", Get_Unique8(11));
'초보의 아웅다웅 설계하기 > STM32' 카테고리의 다른 글
GPIO로 딜레이를 사용하여 Uart TX 출력 - Soft Uart (0) | 2020.07.02 |
---|---|
Demonstrator GUI V2.9.0 RC8 (0) | 2020.05.22 |
SW6STM에서 고정위치에 바이너리 라이팅하기 (0) | 2020.05.20 |
인터럽트 벡터 위치 확인과 변경 (0) | 2020.03.13 |
STM32L432 Write Protection (0) | 2020.03.04 |