FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Author Topic: Using coprocessor (FT813)  (Read 12117 times)

rascalito

  • Newbie
  • *
  • Posts: 8
    • View Profile
Using coprocessor (FT813)
« on: May 04, 2020, 02:27:00 AM »

Hello!

Absolute beginner here. I could initialize the display and draw some basic shapes using the DL
RAM (set COP_SLIDER to 0).
Now I would like to draw a slider (set COP_SLIDER to 1). I read the documentation related to slider,
and found a description of the command layout. That's what I tried to do below.
NB: I'm aware it's shitty code, everything is hardcoded and it shouldn't but it's a test. I will clean
everything once I know how to do.
So my question: what is wrong in this code? I just unwrapped sample code's Send_Cmd which is
basically a wr32 command with some offset management. And the Cmd_slider is a sequence of
Send_cmd, so unrolling everything should look as below...

Thanks for any hint.

Code: [Select]
#define COP_SLIDER 1

void FT813::Test(void) {
#if COP_SLIDER
// Offsets come from BridgeTek's programmers guide, version 1.2, page 204.
wr32(RAM_CMD, CMD_SLIDER); // Command offset is 0
wr16(RAM_CMD + 4, 32); // X
wr16(RAM_CMD + 6, 32); // Y
wr16(RAM_CMD + 8, 320); // W
wr16(RAM_CMD + 10, 32); // H
wr16(RAM_CMD + 12, 0); // Options (default is 0)
wr16(RAM_CMD + 14, 100); // Val
wr16(RAM_CMD + 16, 40); // Size (width of the knob??)
wr16(RAM_CMD + 18, 300); // Range
wr32(RAM_CMD + 20, CMD_SWAP);
#else
wr32(RAM_DL, CLEAR_COLOR_RGB(0x30, 0x60, 0x90)); // Blue
wr32(RAM_DL+4, CLEAR(1,0,0));
wr32(RAM_DL+8, COLOR_RGB(255, 255, 255));
wr32(RAM_DL+12, BEGIN(RECTS));
wr32(RAM_DL+16, VERTEX2F(300, 300));
wr32(RAM_DL+20, VERTEX2F(3000, 600));
wr32(RAM_DL+24, END());
wr32(RAM_DL+28, DISPLAY());
wr8(REG_DLSWAP, DLSWAP_FRAME); // Display list swap
#endif
}
Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 892
    • View Profile
Re: Using coprocessor (FT813)
« Reply #1 on: May 05, 2020, 04:52:17 PM »

Hello,

It looks like your code is just writing the CMD_SLIDER command and its variables with COP_SLIDER = 1, is this correct?
The general structure of a co-processor list when generating a screen is as shown below denoting
the typical starting and ending procedures:
Code: [Select]
[Await REG_CMD_READ == REG_CMD_WRITE and read value of these registers]
#start procedure
CMD_DL_START // Tells co-pro to begin writing DL at RAM_DL+0
CLEAR_COLOR_RGB // Co-processor writes this instruction to the DL
CLEAR(1,1,1) // Co-processor writes this instruction to the DL

#co-pro commands
Color_RGB(0,0,255)
Point_Size(20)
Begin(Points)
Vertex2F(0,0)

#end procedure
End()
DISPLAY // Co-processor writes this instruction to the DL
CMD_SWAP // Co-processor writes REG_DL_SWAP
[update REG_CMD_WRITE to point to end of new commands]
[Await REG_CMD_READ == REG_CMD_WRITE]

Note that the co-processor will not process any of the commands until the second-last step
(writing REG_CMD_WRITE). The processing is complete and the screen will update only after the
last condition (read and write pointers equal) becomes true

Best Regards,
FTDI Community
Logged

rascalito

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Using coprocessor (FT813)
« Reply #2 on: May 06, 2020, 09:40:21 AM »

Hello!

Thanks for your reply.
Yes, that's right, I just want to know how to use the coprocessor to write a single slider.
When I set to COP_SLIDER = 0, it works fine, I get a blue screen with a white rectangle.
I can also draw sliders myself, and that's what I did in the first version of my current software.
It was working well, but it's always difficult to get fancy effects, so I would like to upgrade
my software so that it now uses the coprocessor widgets (for instance in the present case,
a single slider).

Quote
CMD_DL_START // Tells co-pro to begin writing DL at RAM_DL+0

OK, I have added wr32(RAM_DL, CMD_DLSTART);, exactly as if I was writing direcly to the
non-coprocessor area.

Quote
CLEAR_COLOR_RGB // Co-processor writes this instruction to the DL
CLEAR(1,1,1) // Co-processor writes this instruction to the DL

So you mean I don't have to write anything myself? If the coprocessor writes these 2 instructions,
then I have to leave room for these instructions, and then at the end I will write the instructions at offset 8
(4 for clear_color + 4 for clerar(1,1,1)?

Quote
#co-pro commands
Color_RGB(0,0,255)
Point_Size(20)
Begin(Points)
Vertex2F(0,0)

I don't understand this part. What does it do? Do I need it to draw a slider? It looks like it will draw a point.
Is it written in RAM_CMD or RAM_DL? I can write RGB(0,0,255) directly to RAM_DL, so it doesn't look like a
coprocessor command. In my snippet below I

Code: [Select]
#end procedure
End()

Is this End() to be written to the DL memory? If yes, at which offset? Last time I wrote was at offset 8, is it 12 now?

Similarily as before:
Code: [Select]
DISPLAY // Co-processor writes this instruction to the DL
CMD_SWAP // Co-processor writes REG_DL_SWAP

Do I have to do anything here?

Quote
[update REG_CMD_WRITE to point to end of new commands]

How do I do that? I can read where the REG_CMD_WRITE is by rd16(REG_CMD_WRITE + RAM_REG);
but what should I do with the value?

I replaced the DL part with the code found at 2.5.1 in FT81X documentation. I get the FTDI logo on black background.
Same as before, it works with COP_SLIDER = 0, not yet with 1. I guess the missing part is the REG_CMD_WRITE
stuff, but I'm stuck...

Thanks for any hint!

R

Code: [Select]
#define COP_SLIDER 1

void FT813::Test(void) {
#if COP_SLIDER
// Offsets come from BridgeTek's programmers guide, version 1.2, page 204.
// Start procedure
wr32(RAM_DL, CMD_DLSTART);
wr32(RAM_DL + 4, CLEAR_COLOR_RGB(0x30, 0x60, 0x90));
wr32(RAM_DL + 8, CLEAR(1, 1, 1));
// Coprocessor commands
wr32(RAM_CMD, CMD_SLIDER); // Command offset is 0
wr16(RAM_CMD + 4, 32); // X
wr16(RAM_CMD + 6, 32); // Y
wr16(RAM_CMD + 8, 320); // W
wr16(RAM_CMD + 10, 32); // H
wr16(RAM_CMD + 12, 0); // Options (default is 0)
wr16(RAM_CMD + 14, 100); // Val
wr16(RAM_CMD + 16, 40); // Size (width of the knob??)
wr16(RAM_CMD + 18, 300); // Range
// End procedure
wr32(RAM_DL+12, END());
wr32(RAM_DL+16, DISPLAY());
wr8(REG_DLSWAP, DLSWAP_FRAME); // Display list swap
#else
wr32(RAM_DL, CLEAR_COLOR_RGB(0, 0, 0));
wr32(RAM_DL + 4, CLEAR(1, 1, 1)); // clear screen
wr32(RAM_DL + 8, BEGIN(BITMAPS)); // start drawing bitmaps
wr32(RAM_DL + 12, VERTEX2II(220, 110, 31, 'F')); // ascii F in font 31
wr32(RAM_DL + 16, VERTEX2II(244, 110, 31, 'T')); // ascii T
wr32(RAM_DL + 20, VERTEX2II(270, 110, 31, 'D')); // ascii D
wr32(RAM_DL + 24, VERTEX2II(299, 110, 31, 'I')); // ascii I
wr32(RAM_DL + 28, END());
wr32(RAM_DL + 32, COLOR_RGB(160, 22, 22)); // change colour to red
wr32(RAM_DL + 36, POINT_SIZE(320)); // set point size to 20 pixels in radius
wr32(RAM_DL + 40, BEGIN(POINTS)); // start drawing points
wr32(RAM_DL + 44, VERTEX2II(192, 133, 0, 0)); // red point
wr32(RAM_DL + 48, END());
wr32(RAM_DL + 52, DISPLAY()); // display the image
wr8(REG_DLSWAP, DLSWAP_FRAME);

#endif
}




Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 892
    • View Profile
Re: Using coprocessor (FT813)
« Reply #3 on: May 06, 2020, 04:28:04 PM »

Hello,

Sorry the previously example was from a co-processor list (I will link the application note at the end).


So you mean I don't have to write anything myself? If the coprocessor writes these 2 instructions,
then I have to leave room for these instructions, and then at the end I will write the instructions at offset 8
(4 for clear_color + 4 for clerar(1,1,1)?

You would write the commands to RAM_CMD and the co-processor would deal with writing the normal DL commands to RAM_DL

I don't understand this part. What does it do? Do I need it to draw a slider? It looks like it will draw a point.
Is it written in RAM_CMD or RAM_DL? I can write RGB(0,0,255) directly to RAM_DL, so it doesn't look like a
coprocessor command. In my snippet below I

This was just an illustrative example, you would write your slider command here.

You would write the END, DISPLAY and SWAP commands to the co-processor and again this deals with handling normal DL commands.


[update REG_CMD_WRITE to point to end of new commands]

How do I do that? I can read where the REG_CMD_WRITE is by rd16(REG_CMD_WRITE + RAM_REG);
but what should I do with the value?

The idea here is that you update REG_CMD_WRITE with the total length of the commands you have issued to the co-processor then you wait until REG_CMD_WRITE = REG_CMD_READ signalling the commands have been accepted.

Im going to link some useful application notes which cover how all the low level EVE transfers are intended to work:

Application note BRT_AN_006 shows how the SPI transfers work down to bit level and how the data is formatted into the API used by the EVE device itself. This low-level framework is used as the basis for BRT_AN_008. Although written specifically for PIC, the same data transfers and formatting can be used on other MCUs.
https://brtchip.com/wp-content/uploads/Support/Documentation/Application_Notes/ICs/EVE/BRT-AN-006-FT81x-Simple-PIC-Example.pdf

Application note BRT_AN_007 extends the principles shown in BRT_AN_006 to demonstrate how these low level transfers can be used for various widgets and common operations such as text, bitmaps and touch controls.
https://brtchip.com/wp-content/uploads/Support/Documentation/Application_Notes/ICs/EVE/BRT-AN-007-FT81x-Simple-PIC-Example-Demo_Functions.pdf

Application note BRT_AN_008 explains how to create a library for EVE on your MCU, using the PIC18F device as an example. It uses various code layers to provide an intuitive framework so that the main application can use high-level commands from the EVE Programmers Guide whilst the lowest layers translate these to the byte level transfers for the MCU’s SPI Master Interface. The code supports the FT80x and FT81x series.
https://brtchip.com/wp-content/uploads/Support/Documentation/Application_Notes/ICs/EVE/BRT_AN_008_FT81x_Creating_a_Simple_Library_For_PIC_MCU.pdf


Best Regards,
BRT Community
Logged

rascalito

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Using coprocessor (FT813)
« Reply #4 on: May 10, 2020, 09:54:53 AM »

Hello!

Thanks for your reply. I managed to use the widgets.
I wrote my own code, and I could test all the widgets listed page 152 of the documentation... except the CMD_NUMBER.
I spent quite some time on it, I checked what exactly I send with the oscilloscope, and what I wrote seems to be coherent
with what should be sent.
The documentation says:
Code: [Select]
void cmd_number( int16_t x,
    int16_t y,
    int16_t font,
    uint16_t options,
    int32_t n );

I have attached the part of the command itself. One is for CMD_TOGGLE (which works and displays fine),
the other is for CMD_NUMBER (which doesn't work and screws up everything. If I use CMD_NUMBER, even
other commands don't display anymore).
As I don't see my attachments in preview, here is the contents:
CMD_TOGGLE:
Code: [Select]
B0 80 18 12 FF FF FF    // 0xFFFFFF12 is CMD_TOGGLE. The address is 0x308000 + write bit + current offset (0x18)
B0 80 1C 64 00 64 00    // X and Y parameters are passed, both of them 100 (0x64), at updated offset (0x1C)
B0 80 20 1E 00 14 00    // width = 30 (1E), font = 20 (14)
B0 80 24 00 00 00 00    // Option and state both 0
B0 80 28 4F 46 46 00    // String "OFF"

This works fine. Now if I replace the above at the same place in my code with CMD_NUMBER, x, y, font, options, number,
the scope reports:
CMD_NUMBER:
Code: [Select]
B0 80 18 38 FF FF FF    // CMD_NUMBER is 0xFFFFFF38, written at the same offset as before (0x18)
B0 80 1C 14 00 3C 00    // 20, 60 for the coordinates (14, 3C). The same code line works for all other widgets and has been copied.
B0 80 20 1F 00 00 00    // Font = 1F (31). This font works for other widgets. Options = 0 as in some documentation examples.
B0 80 24 2A 00 00 00    // Value = 42 (not original, it's the same as the documentation).

The code preceding this sequence and also the code following are strictly identical.

Can anybody explain me why CMD_NUMBER doesn't work?
Well, I have a workaround with CMD_TEXT, by sending a formatted string instead of using CMD_NUMBER,
but it would be good to know why it doesn't work.
Thanks.

« Last Edit: May 11, 2020, 01:27:50 PM by rascalito »
Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 892
    • View Profile
Re: Using coprocessor (FT813)
« Reply #5 on: May 12, 2020, 04:44:17 PM »

Hello,

I believe you are sending the CMD_SETBASE (0xffffff38) command when you are trying to use CMD_NUMBER (0xffffff2e).
can you try adjusting your code accordingly and let me know how you get on?

Best Regards,
FTDI Community
Logged

rascalito

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Using coprocessor (FT813)
« Reply #6 on: May 15, 2020, 07:09:35 AM »

Hello!

Thanks for your reply, and sorry for the delay, I was dealing with real work (i.e.
the one I get paid for)...
It works with 0xffffff2e, thanks. That said, I don't know how this definition came here,
I didn't invent it and I didn't make the file myself. I downloaded it from GitHub, most likely.
The only thing I did is to define all the commands as absolute, not as an offset from RAM start.

Thanks anyway.

Best regards,

R.
Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 892
    • View Profile
Re: Using coprocessor (FT813)
« Reply #7 on: May 18, 2020, 01:56:07 PM »

Hello,

Glad you've managed to get it working!

Best Regards,
BRT Community.
Logged