How to port ILI9341 driver from AVR to PSoC4 component?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello everyone,

   

I'd like to port my TFT ILI9341 AVR driver (parallel bus) from AVR architecture to the PSoC4 component but I don't know how to assign PSoC port's symbolic names for used ports in order to have them correct when I use the component in the schematic etc. Could you give me some tips? Robert

   

PS.

   

The driver was attached as ZIP file.

0 Likes
29 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

When placing I/O pins you are giving them your own symbolic name. Moreover you can specify that the pins are kept on a single port or might be on different ports. In the .cydwr view of your project you are assigning symbolic pin-names to real pins. Read the "System Reference Guide" from Creator Help-menu and the pins datasheet.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Could you type the names and show me how should I use them? Robert

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Watch some of this videos.

   

 

   

Bob

0 Likes
Anonymous
Not applicable
        I watched all of them but didn't find what I was looking for. Robert   
0 Likes
EvPa_264126
Level 7
Level 7
500 replies posted 250 replies posted 100 likes received

Perhaps you need to do a  search on the forum:  http://www.cypress.com/search/all/ILI9341
for example here: SPI TFT Color LCD240x320 +SD
there is an example for the PSoC4 and ILI9341 (SPI):  TFT240_320_SD.zip
for parallel, but - for the other drivers here.

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Robiw: I wouldn't do a parallel bus to drive the ILI9341 it works best with SPI and is easier to interface to the LCD and the PSOC 4. I am sending you a program that works with the CY8CKIT-049-42XX Prototyping kit board.  It was done on the PSOC Creator 3.3 SP1 (3.3.0.7343) program. If you want to run it on a PSOC 4 Pioneer board or another version of PSOC you will have to change the device.

0 Likes
Anonymous
Not applicable

Dear Colleagues,

   

Thank you for your help. But the problem is pretty different. As I have written I have the AVR ILI9341 library and I don't want to use SPI but parallel mode. I'd like to port my OWN library to the PSoC component. I have definitions as follows:

   

#define TFT_DATA_PORT PORTA
#define TFT_DATA_DDR DDRA
#define TFT_CTRL_PORT PORTB
#define TFT_CTRL_DDR DDRB
#define WRX_PIN PB1  //Write signal
#define RDX_PIN PB7  //Read signal
#define CSX_PIN PB3  //Chip select signal
#define DCX_PIN PB2  //Command/Data signal: 1->DRAM data, 0->Command
#define RESX_PIN PB4  //Reset signal

   

etc.. and still wondering how to change them to the PSoC component style in order to bind them to the schematic pin names within the component. In other words I'd like to design my own component with the presented code. Best regards... Robert

0 Likes
EvPa_264126
Level 7
Level 7
500 replies posted 250 replies posted 100 likes received

I can offer an example of 8-bit parallel for PG-12864A:  GLCD_128x64_PSoC4.zip      here
You can create a test project - so it will be easier to understand what your problem is.

0 Likes
Anonymous
Not applicable

Thank you for your project but it is simple c-file project. You used the pin component, some simple c-code that uses specific pin components names, not the your own TFT/LCD component. It doesnt cover my question. Best regards...Robert

0 Likes
Anonymous
Not applicable

The goal is how to use the component terminal names within the component C and H files to sets the port direction, state etc. This component only uses Symbol and API (C/H file)...Robert

0 Likes
Anonymous
Not applicable

For example: my own component uses two output terminals named OUTA and OUTB.

   

Now, I'm going to write definitions in the API component.h file as follows:

   

# define OUTPUT_PORT_A OUTA
​# define OUTPUT_PORT_A OUTB

   

​but I cannot do this this way because it would never work. The next step for the h.file is to set direction and state of this port (to define marcos) which will relate to actual chip port connected within the project schematic... I don't know how to explain the problem better... Robert

0 Likes
EvPa_264126
Level 7
Level 7
500 replies posted 250 replies posted 100 likes received

Something like this:

   

you driwer:
----------------------
#define TFT_CTRL_PORT PORTB    // port in you projec
#define WRX_PIN PB1  //Write signal
#define RESET_WRX TFT_CTRL_PORT &= ~(1<<WRX_PIN)
.....
for PSoC4:
---------------
#define TFT_CTRL_PORT  OUTB    // port in PSoC4 project                 
#define WRX_PIN 0x01 //Write signal  0x01 - num   pin in  OUTB    
#define RESET_WRX    Write_TFT_CTRL_PORT (Read_FT_CTRL_PORT& ~(1<<WRX_PIN));      
....

0 Likes
Anonymous
Not applicable

Hi,

   

You still don't understand the problem. When you design your own component you don't know the port name your component will be connected to. So you cannot type the port name but something like reference to the component pin name... Robert

0 Likes
Anonymous
Not applicable

OK, I found this. It should be something like this:

   

`$INSTANCE_NAME`_Pin_OUTA_Write(LOW);

   

 

   

etc... right? Robert

0 Likes
EvPa_264126
Level 7
Level 7
500 replies posted 250 replies posted 100 likes received

When you create a component - each element has a name.
The choice you make contact in the file * .cydwr
connection - through the component name and the name of the element:
static void `$INSTANCE_NAME`_SetupIO(void)
{
    `$INSTANCE_NAME`_LCD_DATA_Write(0);
    
    CyPins_ClearPin(`$INSTANCE_NAME`_LCDC_E);
    CyPins_ClearPin(`$INSTANCE_NAME`_LCDC_CS1);
    CyPins_ClearPin(`$INSTANCE_NAME`_LCDC_CS2);
.........
old example GLCD component   GLCD128x64.zip      here
Again, i not guessing? )))

0 Likes
Anonymous
Not applicable

Ufff, OK. Now everything starts to be clear. Thanks! Robert

   

PS.
After designing the component within a sample project could I copy it to my library by starting library project? 

0 Likes
EvPa_264126
Level 7
Level 7
500 replies posted 250 replies posted 100 likes received

The process of creating the component a little bit different, I do not remember.
You should read the Component Author Guide

0 Likes
Anonymous
Not applicable

You propably meant the library, not component...R

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Due to the way the Psoc 4 works and the pin limitations you need to make registers to drive the ILI9341 device.  I am sending you an APP sheet on how this should be setup. I still think you should use the SPI for the Psoc 4 if you want to do  Parallel bus I would upgrade to the Psoc 5lp it already has a component library for this part. and it can drive an 8 bit bus on one port of the Psoc  with out using the registers that you must use when using the Psoc 4. 

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

You might want to look at this program for ideals on how to use the registers in a library device.

0 Likes
Anonymous
Not applicable

Hi,

   

Thank you for your help, but in fact I don't know for what reasons I should use register component to make my own component? I'm going to use pin component to create my own ili9341 component and just write/read to data register of the 8-bit port as many people do. Could you explain? R

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

On the Psoc 4 Pioneer you only have 8 bit port but you also need the control signals to be there at the same time.  That is why you need the registers so that you can load them and them apply them all at once to the ILI9341. I am sending you the data sheet so you can look at the signals required. Look at page 66 where it shows an 8 bit processor and shows the control lines necessary for the part to function. Also a lot of pins are not usable for an 8 bit port due to the Pioneer board design and if you need to span a port you need the registers.

0 Likes
Anonymous
Not applicable

Hello bobgoar,

   

If you look at the first post where I have attached my AVR driver (working pretty well) you will find that I HAD TO be sure that we need extra ports for controlling TFT ;-). But you are not exactly right that control signals should be write at once. In fact they should be write one by one. Like follows:

   

void writeCommand(uint8_t Command)
{
RESET_DCX; //Command
RESET_WRX;
TFT_DATA_PORT = Command;
SET_WRX; //TFT reads data at the rising edge
SET_DCX; //DCX is 1 by default to increase DRAM data transfer
}

   

This way I don't know for what reasons I should use registers in place of simple pin component (one 8-bit pin component and the others as 1-bit pin components). Of course, this way I need one 8-bit port. Best regards... Robert

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

It is quite easy:

   

RESET_DCX; //Command  This is equivalent to a Pin_DCX_Write(0); assuming you named the pin "Pin_DCX"
RESET_WRX; Same: Pin_WRX_Write(0);
TFT_DATA_PORT = Command; Port_Write(Command); Writes multiple bits to the pins named "Port"
SET_WRX; //TFT reads data at the rising edge Pin_WRX_Write(1);
SET_DCX; //DCX is 1 by default to increase DRAM data transfer Pin_DCX_Write(1);
 

   

Hope that helps

   

Bob

0 Likes
Anonymous
Not applicable

I know that it is easy. My post referred to the bobgoar post that I need to use register component, not pin/port component due to the fact that signals need to be written at once...R

0 Likes
Anonymous
Not applicable

Assuming that we have one pin component (but 8-bit wide) named DATA how we could write to entrie port from API and to one bit of this port? R

   

PORT_Write(Byte)

   

and PORT_0_Write(Bit)

   

?

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

When attempting to write only to a single bit of a port I would suggest to use a shadow-register. But your code snippet for writing to your device does not show a requirement for writing single port-bits.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

I will use one 8-bit wide pin component and few separate 1-bit wide pin components. So I will have to write to entire port and single pins of other ports... R

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

(...)and to one bit of this port? so you do not need that.

   

There are different routing capabilities for ports numbered >= 4. Use those for the single-bit signals and a port where no board hardware is attached to (mind the caps!!! See schematic) for the 8-bit wide interface. Differently from your AVR the "Port" in a PSoC is not such a strong definition. Keep in mind that -as one of the last steps in project design- the named pins on the schematic (topdesign) get associated to a physical numbered pin.

   

 

   

Bob

0 Likes