Using eDMA K22 to transfer data to a TFT LCD

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using eDMA K22 to transfer data to a TFT LCD

Jump to solution
1,668 Views
danielecortella
Contributor V

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 

Labels (1)
Tags (4)
1 Solution
1,352 Views
egoodii
Senior Contributor III

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:

View solution in original post

7 Replies
1,352 Views
danielecortella
Contributor V

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

0 Kudos
1,352 Views
danielecortella
Contributor V

up

Thanks

0 Kudos
1,352 Views
danielecortella
Contributor V

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

0 Kudos
1,353 Views
egoodii
Senior Contributor III

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:

1,352 Views
Kan_Li
NXP TechSupport
NXP TechSupport

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.

pastedImage_3.png


Hope that helps,
Have a great day,
Kan

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
1,352 Views
danielecortella
Contributor V

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

0 Kudos
1,352 Views
egoodii
Senior Contributor III

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))