有个问题需要请教一下,关于M3核的位带别名区地址的问题。我如果对GPIO70这个管脚进行位操作,现在知道GPIOC的基址为0x40006000,GPIODATA的偏移地址为0x00,根据手册中的公式bit_word_addr = bit_band_base + (byte_offset x 32) + (bit_number × 4),bit_band_base为0x42000000,byte_offset为0x40006000,现在不知道bit_number的值应为多少?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
有个问题需要请教一下,关于M3核的位带别名区地址的问题。我如果对GPIO70这个管脚进行位操作,现在知道GPIOC的基址为0x40006000,GPIODATA的偏移地址为0x00,根据手册中的公式bit_word_addr = bit_band_base + (byte_offset x 32) + (bit_number × 4),bit_band_base为0x42000000,byte_offset为0x40006000,现在不知道bit_number的值应为多少?
GPIO70是PC6,bit_number是 0x00000040 ,请参考下面的程序,:
void
GPIOPinWrite(unsigned long ulPort, unsigned char ucPins, unsigned char ucVal)
{
// Check the arguments.
ASSERT(GPIOBaseValid(ulPort));
// Write the pins.
HWREG(ulPort + (GPIO_O_DATA + (ucPins << 2))) = ucVal;
}
#define GPIO_PIN_0 0x00000001 // GPIO pin 0
#define GPIO_PIN_1 0x00000002 // GPIO pin 1
#define GPIO_PIN_2 0x00000004 // GPIO pin 2
#define GPIO_PIN_3 0x00000008 // GPIO pin 3
#define GPIO_PIN_4 0x00000010 // GPIO pin 4
#define GPIO_PIN_5 0x00000020 // GPIO pin 5
#define GPIO_PIN_6 0x00000040 // GPIO pin 6
#define GPIO_PIN_7 0x00000080 // GPIO pin 7
<<2代表左移2位。
GPIO本身就有bit-mask,不需要用bit-band,上面谈到的例程是bit-mask。(bit-mask的原理请参考Technical Reference Manual的GPIO章节的Data Register Operation。)
如果一定要用bit-band。那么bit-mask的GPIODATA的通用地址的offset是0x003FC,GPIOC的地址是0x40006000,对应的bit-band是
0x42000000+0x063FC*32+7*4=0x420C7F9C