EasyManua.ls Logo

TELINK SEMICONDUCTOR TLSR8232 - MCU Address Space Access; Peripheral Space Access

Default Icon
211 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Telink TLSR8232 BLE SDK Developer Handbook
AN-19112700-E1 29 Ver.1.0.0
7) bss
“data” is followed by “bss”. Since the first array_start_bss_” should be 16-byte aligned,
the “bss” section starts from 0x80a2a0, and its size is 0xc98, as shown in Figure 2-3.
The final variable in “bss” is “blt_ota_start_tick”, a int variable. Its address is 0x80af34,
and its size is 4-byte. Therefore the ending address of “bss” is 0x80af38, and the size of
the “bss” is 0x80af38 - 0x80a2a0 = 0xc98, as shown in Figure 2-3.
By calculation the remaining SRAM space size is 0x80c000 0x80af38 = 0x10c8 = 4296
bytes, from which minus 256 bytes for stack, the remaining 4040 bytes are unused.
2.1.3 MCU Address Space Access
MCU address space 0x000000 ~ 0xffffff can be accessed in the program in the following
two cases.
2.1.3.1 Peripheral Space Access
The peripheral space (register & SRAM) is directly accessed (read/write) via pointer.
u8 x = *(volatile u8*)0x800066; // read register 0x66
*(volatile u8*)0x800066 = 0x26; // write register 0x66
u32 y = *(volatile u32*)0x808000; // read SRAM 0x8000-0x8003
*(volatile u32*)0x808000 = 0x12345678; // write SRAM 0x8000-0x8003
In the program, functions including “write_reg8”, “write_reg16”, “write_reg32”,
“read_reg8”, “read_reg16” and “read_reg32”, which implement pointer operation, are
used to write or read the peripheral space correspondingly. Please see
drivers/5316/bsp.h” for details.
Please note that for operations such as write_reg8 (0x8000), read_reg16 (0x8000) ,
whose definitions are shown as below, the base address 0x800000” is automatically
added (address line BIT(23) is 1) to ensure the access space is Register/SRAM rather
than Flash.
#define REG_BASE_ADDR 0x800000
#define write_reg8(addr,v) U8_SET((addr + REG_BASE_ADDR),v)
#define write_reg16(addr,v) U16_SET((addr + REG_BASE_ADDR),v)
#define write_reg32(addr,v) U32_SET((addr + REG_BASE_ADDR),v)
#define read_reg8(addr) U8_GET((addr + REG_BASE_ADDR))
#define read_reg16(addr) U16_GET((addr + REG_BASE_ADDR))
#define read_reg32(addr) U32_GET((addr + REG_BASE_ADDR))
Please pay attention to one thing of memory alignment: If a pointer pointing to 2 bytes/4
bytes is used to access the peripheral space, make sure the address is 2-byte/4-byte
aligned to avoid data read/write error. The following shows two incorrect formats:
u16 x = *(volatile u16*)0x808001; // 0x808001 is not 2-byte aligned
*(volatile u32*)0x808005 = 0x12345678; // 0x808005 is not 4-byte aligned

Table of Contents