2464 views|4 replies

2865

Posts

4

Resources
The OP
 

Keil compilation and bit-band operation issues [Copy link]

According to the records, STM32G431 uses the cortex-M4 core, which should be able to use the bit-band operation address function. Now I want to use bit-band operation, but I check the keil project compilation definition. IRAM=20000000, SIZE=8000, the on-chip SRAM is 32K in size, and now I am wondering, does the keil variable memory allocation start from 20000000? Or 20008000?

Also, what are the uses of IRAM2 memory?

Experts please answer!

This post is from stm32/stm8

Latest reply

Automatically generate code, you don't have to worry about where the code starts, where it is placed, size, etc. Reduce development time   Details Published on 2019-12-21 10:14
 

2865

Posts

4

Resources
2
 

Sorry this question is so stupid!!! I figured it out myself. Any variable can use bit-banding operation as long as it is in the SRAM area or peripheral address!

Just use

#define BITBAND(addr, bitnum)((addr & 0xF0000000)+0x2000000+((addr & 0xFFFFF)<<5)+(bitnum<<2))  
#define MEM_ADDR(addr) *((volatile unsigned long *) (addr))
These two macros will do.

Thank you everyone!

This post is from stm32/stm8
 
 

2865

Posts

4

Resources
3
 
#define BITBAND(addr, bitnum)((addr & 0xF0000000)+0x2000000+((addr & 0xFFFFF)<<5)+(bitnum<<2))  #define MEM_ADDR(addr)  *((volatile unsigned long *) (addr))

uint8_t bitband = 0x0;
//执行到此处死机了!!!
MEM_ADDR(BITBAND(bitband,2)) = 0x1; 
printf("bit=%02x\r\n",bitband);

The program can be compiled, but it freezes when it reaches MEM_ADDR(BITBAND(bitband,2)) = 0x1;

This post is from stm32/stm8
 
 

15

Posts

0

Resources
4
 

You can also read the G431 information, or even simpler, use cubeMX to automatically generate the bare metal initial keil code, don’t you have it all?

This post is from stm32/stm8
 
 
 

15

Posts

0

Resources
5
 

Automatically generate code, you don't have to worry about where the code starts, where it is placed, size, etc. Reduce development time

This post is from stm32/stm8
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list