Hello,
i have a device where i have MK22FX connected to a sdcard with the SDHC periferical and a LCD TFT. I have to read the data image from the sdcard and write this to the LCD that is interfaced with a 8bit parallel port. Every byte write to the TFT need to be validate with a rising edge of a GPIO of write. My question is if it is possible program the eDMA to control also this pin so all the data transfer is done only with the eDMA.
It is my first time that i want to use this periferical.
Thanks
Solved! Go to Solution.
The LSB is indeed what interacts with the bit-banding hardware. So yes, to 'set' your bit:
BITBAND_REG(GPIOD_PDOR, 2) = 1;
A particular place where 'bit band' hardware and macro come in VERY handy is to test a Boolean flag bit in a register, and especially for 'write 1 clear' w1c bits in such registers for 'interrupt acknowledge' without RMW or disturbing anything else!
if( BITBAND_REG(I2S0_RCSR, I2S_RCSR_FEF_SHIFT) )
0x10ee4: 0xf8df 0x1ae0 LDR.W R1, [PC, #0xae0] ; [0x119c8] 0x425e1048 (1113460808)
0x10ee8: 0x6809 LDR R1, [R1]
0x10eea: 0xb119 CBZ R1, ??I2S0_RX_IRQHandler_3 ; 0x10ef4
BITBAND_REG(I2S0_RCSR, I2S_RCSR_FEF_SHIFT) = 1;
0x10eec: 0xf8df 0x1ad8 LDR.W R1, [PC, #0xad8] ; [0x119c8] 0x425e1048 (1113460808)
0x10ef0: 0x2201 MOVS R2, #1
0x10ef2: 0x600a STR R2, [R1]
??I2S0_RX_IRQHandler_3:
Hello,
with my new pcb i'm trying this solution but i have a problem.
I have to set the pin of LCD_WR high and then low
GPIO_WritePinOutput(LCD_WR_GPIO_BASE, LCD_WR_GPIO_PIN, false);//write low
tmp = GPIOC->PDOR & 0xFFFFFF00;
GPIOC->PDOR = tmp | data;
GPIO_WritePinOutput(LCD_WR_GPIO_BASE, LCD_WR_GPIO_PIN, true);//write high
so i have modified the function as
BITBAND_REG(GPIOB->PDOR, LCD_WR_GPIO_PIN) = 1;//write low
tmp = GPIOC->PDOR & 0xFFFFFF00;
GPIOC->PDOR = tmp | data;
BITBAND_REG(GPIOB->PDOR, LCD_WR_GPIO_PIN) = 0;//write high
where
LCD_WR_GPIO_PIN 21U
the BITBAND_REGADDR function in defined in the MK22 file as:
/**
* @brief Macro to calculate address of an aliased word in the peripheral
* bitband area for a peripheral register and bit (bit band region 0x40000000 to
* 0x400FFFFF).
* @param Reg Register to access.
* @param Bit Bit number to access.
* @return Address of the aliased word in the peripheral bitband area.
*/
#define BITBAND_REGADDR(Reg,Bit) (0x42000000u + (32u*((uint32_t)&(Reg) - (uint32_t)0x40000000u)) + (4u*((uint32_t)(Bit))))
/**
* @brief Macro to access a single bit of a peripheral register (bit band region
* 0x40000000 to 0x400FFFFF) using the bit-band alias region access. Can
* be used for peripherals with 32bit access allowed.
* @param Reg Register to access.
* @param Bit Bit number to access.
* @return Value of the targeted bit in the bit band region.
*/
#define BITBAND_REG32(Reg,Bit) (*((uint32_t volatile*)(BITBAND_REGADDR((Reg),(Bit)))))
#define BITBAND_REG(Reg,Bit) (BITBAND_REG32((Reg),(Bit)))
but the code dosn't work. Can you help me?
Thanks
up
Thanks
Hello,
thanks for the reply. So if i want to write high the GPIOD PIN2 for example i have to set:
Reg Register = GPIOD_PDOR is 400F_F0C0h base
Bit Bit = 2
so i have the bitband address, writing 1 on this i will set the bit:
*(calcuate_address) = 0x1U
right?
Thanks
The LSB is indeed what interacts with the bit-banding hardware. So yes, to 'set' your bit:
BITBAND_REG(GPIOD_PDOR, 2) = 1;
A particular place where 'bit band' hardware and macro come in VERY handy is to test a Boolean flag bit in a register, and especially for 'write 1 clear' w1c bits in such registers for 'interrupt acknowledge' without RMW or disturbing anything else!
if( BITBAND_REG(I2S0_RCSR, I2S_RCSR_FEF_SHIFT) )
0x10ee4: 0xf8df 0x1ae0 LDR.W R1, [PC, #0xae0] ; [0x119c8] 0x425e1048 (1113460808)
0x10ee8: 0x6809 LDR R1, [R1]
0x10eea: 0xb119 CBZ R1, ??I2S0_RX_IRQHandler_3 ; 0x10ef4
BITBAND_REG(I2S0_RCSR, I2S_RCSR_FEF_SHIFT) = 1;
0x10eec: 0xf8df 0x1ad8 LDR.W R1, [PC, #0xad8] ; [0x119c8] 0x425e1048 (1113460808)
0x10ef0: 0x2201 MOVS R2, #1
0x10ef2: 0x600a STR R2, [R1]
??I2S0_RX_IRQHandler_3:
Hi Daniele,
There is a bit-band region allowing user to access the GPIO module, so you may use eDMA to transfer data to this space to control the GPIO pin rise or fall. Please kindly refer to the following for details.
Hope that helps,
Have a great day,
Kan
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello,
on my kinetis datasheet is written that the bitband GPIO controller address is 0x400F_F000. So my question is, if i want to write a 1 to the GPIOC0 how i have to calculate the address where to write?
Thanks
Use the BitBand macros in your processor header.
Probably like these:
/**
* @brief Macro to calculate address of an aliased word in the peripheral
* bitband area for a peripheral register and bit (bit band region 0x40000000 to
* 0x400FFFFF).
* @param Reg Register to access.
* @param Bit Bit number to access.
* @return Address of the aliased word in the peripheral bitband area.
*/
#define BITBAND_REGADDR(Reg,Bit) (0x42000000u + (32u*((uint32_t)&(Reg) - (uint32_t)0x40000000u)) + (4u*((uint32_t)(Bit))))
/**
* @brief Macro to access a single bit of a peripheral register (bit band region
* 0x40000000 to 0x400FFFFF) using the bit-band alias region access. Can
* be used for peripherals with 32bit access allowed.
* @param Reg Register to access.
* @param Bit Bit number to access.
* @return Value of the targeted bit in the bit band region.
*/
#define BITBAND_REG32(Reg,Bit) (*((uint32_t volatile*)(BITBAND_REGADDR(Reg,Bit))))
#define BITBAND_REG(Reg,Bit) (BITBAND_REG32(Reg,Bit))