BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: What is the purpose of CMD_REGREAD?  (Read 9003 times)

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
What is the purpose of CMD_REGREAD?
« on: May 21, 2023, 03:49:32 PM »

What is CMD_REGREAD supposed to be used for?
It does not seem to have any use when building a display-list and outside of display list handling it is more efficient to read from the address directly.

I am playing with EVE_cmd_regread() and EVE_memRead32() on a BT817 - the results are the same for the most part.

Code: [Select]
for(uint8_t index=0; index < 32; index++)
{
    test1[index] = EVE_cmd_regread(0x302000UL + (index*4));
    test2[index] = EVE_memRead32(0x302000UL + (index*4));
}

Some of the not documented registers seem to be pretty usefull, like 0x3021A8UL + 0x3021ACUL, I wonder why these are not documented.
Reading from the not documented REG_DATESTAMP returned a string: "2019-10-28_2.5.3"
Reading from for example 0x303000 returns 0xdeadbeef.
Reading from 0x309218 returns 3, whatever that means. :-)

Reading from RAM_JTBOOT (0x30b000) is returning inconsistent results between EVE_cmd_regread() and EVE_memRead32(), not like EVE_cmd_regread() is executed with higher privilege, more like what is returned for this memory region is not actually accessible for both functions.

The region from 0x309000 to 0x30914e has a few documented registers like REG_TRACKER and REG_FLASH_SIZE,
it is not mentioned in the memory map though, "Table 5-1 BT817/8 Memory Map".


I also had a look at the code for BRT_AN_025.
The functions EVE_CMD_REGREAD(), EVE_CMD_GETPROPS(), EVE_CMD_FONTCACHEQUERY(), EVE_CMD_GETIMAGE() and EVE_CMD_GETPTR()
are not implemented to do anything usefull and all these write out the parameters to EVE that are return parameters.
There is EVE_LIB_GetProps() though.

EVE_CMD_PCLKFREQ() does write the parameter "factual" although this is a return parameter.
EVE_CMD_FLASHFAST() does write the parameter "result" although this is a return parameter.
EVE_CMD_MEMCRC() does write the parameter "result" although this is a return parameter.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 732
    • View Profile
Re: What is the purpose of CMD_REGREAD?
« Reply #1 on: May 25, 2023, 01:56:07 PM »

Hi Rudolph,

As you said, in most application cases where the MCU wants to read or write, a standard SPI write would be most efficient.
There can be cases where it may be beneficial such as to reduce latency. e.g. if you want to do a read immediately after an operation which uses the co-processor, then waiting for the command to complete and then doing a SPI read would have more latency than adding a REGREAD command in your list of commands. For latency, one case may be reading the REG_CLOCK.
You could also write many registers together even if not in adjacent registers (e.g. call CMD_PCLKFREQ and then write the display registers)

For RAM_JBOOT, this is not designed to be accessed from the host MCU directly and so should only be used with the recommended methods (such as the custom touch settings in the BT817 datasheet)

Yes, we have implemented the commands in BRT_AN_025 directly and so they just add a dummy value which is replaced by the co-processor. We tend to use helper functions instead which then wrap those into more useful commands where you get the value back from the function (via return or pointer). We will look at adding some more of the EVE_LIB functions as helpers in the examples which we are producing for BRT_AN_025 to make these easier to use though, and so thanks for your feedback on this point.

Best Regards, BRT Community
Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: What is the purpose of CMD_REGREAD?
« Reply #2 on: May 25, 2023, 08:19:13 PM »

As you said, in most application cases where the MCU wants to read or write, a standard SPI write would be most efficient.
There can be cases where it may be beneficial such as to reduce latency. e.g. if you want to do a read immediately after an operation which uses the co-processor, then waiting for the command to complete and then doing a SPI read would have more latency than adding a REGREAD command in your list of commands. For latency, one case may be reading the REG_CLOCK.

Ah, yes, thank you.
That is probably not something I will ever use but latency is a good argument.
Then I maybe should change how my function currently works as right now I have it implemented as stand-alone command.
And thinking about it, I would rather use CMD_MEMCPY to read some register as it can be anywhere in the list of commands.
CMD_REGREAD would be something for the end of the command-list since it writes to RAM_CMD and then you need to find out to where exactly.
As I am using REG_CMDB_WRITE (I dropped FT80x support), I am not keeping track of where in RAM_CMD EVE currently is,
so I could not even make my EVE_cmd_regread() function return the offset for reading out the value later.

Quote
You could also write many registers together even if not in adjacent registers (e.g. call CMD_PCLKFREQ and then write the display registers)

Yes - but what do you mean in context of CMD_REGREAD?

Quote
For RAM_JBOOT, this is not designed to be accessed from the host MCU directly and so should only be used with the recommended methods (such as the custom touch settings in the BT817 datasheet)

I am aware, but I still had to try out if using CMD_REGREAD is working differently in this region. :-)

Quote
Yes, we have implemented the commands in BRT_AN_025 directly and so they just add a dummy value which is replaced by the co-processor. We tend to use helper functions instead which then wrap those into more useful commands where you get the value back from the function (via return or pointer). We will look at adding some more of the EVE_LIB functions as helpers in the examples which we are producing for BRT_AN_025 to make these easier to use though, and so thanks for your feedback on this point.

I also find the documentation for these odd, or rather the given C function prototypes.

I implented
void EVE_cmd_fontcachequery(uint32_t *p_total, int32_t *p_used);
and not
void cmd_fontcachequery( uint32_t total, int32_t used );

My function does not write the values to RAM_CMD, it writes two 0UL and then reads from RAM_CMD and
writes back the retreived values if the pointers are not NULL.

Additionally, using "int32_t" for "used" does not seem to make any sense here.
Even your own example code agrees with me on this:

Code: [Select]
uint32_t total, used;
uint16_t ram_fifo_offset = rd16(REG_CMD_WRITE);
cmd_fontachequery(total, used);
total = rd32(RAM_CMD + (ram_fifo_offset + 4) % 4096);
used = rd32(RAM_CMD + (ram_fifo_offset + 8) % 4096);

It should not be possible for "used" to ever have a negative value.

Please review every single signed parameter and change it to unsigned when applicable. :-)
I wrote this at least once before in some other post here, a signed radius parameter for CMD_CLOCK makes no sense and there are likely more examples to be found.
« Last Edit: May 26, 2023, 05:50:33 AM by Rudolph »
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 732
    • View Profile
Re: What is the purpose of CMD_REGREAD?
« Reply #3 on: May 29, 2023, 04:47:38 PM »

Hi Rudolph,

Thanks for your feedback, yes we are going through the Programmers Guide to review the data types and we will update them where applicable. As you said, some of the signed/unsigned types are not the optimal ones.

For the CMD_REGREAD, sorry meant to also mention CMD_MEMWRITE in that reply. You could use the CMD_REGREAD and CMD_MEMWRITE so that you can do reads and writes with low latency between them.

Best Regards, BRT Community
Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: What is the purpose of CMD_REGREAD?
« Reply #4 on: May 30, 2023, 07:09:14 PM »

Hello,

Thanks for your feedback, yes we are going through the Programmers Guide to review the data types and we will update them where applicable. As you said, some of the signed/unsigned types are not the optimal ones.

Thank you, I will gladly remove a couple of casts then. :-)

Quote
For the CMD_REGREAD, sorry meant to also mention CMD_MEMWRITE in that reply. You could use the CMD_REGREAD and CMD_MEMWRITE so that you can do reads and writes with low latency between them.

Oh, CMD_MEMWRITE.
I implemented it, again as standalone command like I still have CMD_REGREAD.
And then I commented it out and tagged it as pointless.
I did not even get around implementing it with support for more than 4kiB of data.
Ok, I admit the low latency argument gives this command purpose, at least when using it with well below 4kiB of data.
But I still can not come up with any real use case, outside of perhaps testing the chip that is.
I like to make EVE cry, obviously. :-) But certainly not when doing an actual application.
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 732
    • View Profile
Re: What is the purpose of CMD_REGREAD?
« Reply #5 on: May 31, 2023, 02:59:06 PM »

Hi Rudolph,

Yes both CMD_REGREAD and CMD_MEMWRITE are much less commonly used than the normal SPI write/read but useful to have for those kinds of uses.

We'll post back when the programming guide updates are completed,

Best Regards, BRT Community

 
Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: What is the purpose of CMD_REGREAD?
« Reply #6 on: September 25, 2023, 07:59:52 PM »

A bit off-topic but I mentioned it here before that the variable types are partly not correct.

And I just found another one: void cmd_rotate( int32_t a );
The range for "a" is 0 to 65535.
Yes, this needs to be 32 bit as everything in RAM_CMD needs to be 32 bit aligned.
But please change this in the programming guide to the unsigned value it actually is.

Same in cmd_rotatearound(x,y,a,s), "x" and "y" need to be signed, "a" does not and I am not actually sure about "s".

void cmd_fontcachequery( uint32_t total, int32_t used ); - what about "used"?
void cmd_fontcache( uint32_t font, int32_t ptr, uint32_t num ); - the "ptr" is for a RAM_G address
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 732
    • View Profile
Re: What is the purpose of CMD_REGREAD?
« Reply #7 on: September 26, 2023, 01:45:38 PM »

Hello Rudolph,

Thank you for your feedback, i will pass this along to be updated in the next version of the programmers guide.

Best Regards,
BRT Community
Logged

Domdom

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: What is the purpose of CMD_REGREAD?
« Reply #8 on: October 03, 2023, 03:22:39 AM »

While doing a CMD_CALLLIST, CMD_REGREAD is the only way to read a register. Similar to CMD_MEMWRITE.
« Last Edit: October 03, 2023, 03:29:04 AM by Domdom »
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 732
    • View Profile
Re: What is the purpose of CMD_REGREAD?
« Reply #9 on: October 03, 2023, 03:33:41 PM »

Hello,

Yes this is correct, the only way to perform a register read from a display list or via the co-processor is with CMD_REGREAD or CMD_MEMCPY.

Best Regards,
BRT Community
Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 389
    • View Profile
Re: What is the purpose of CMD_REGREAD?
« Reply #10 on: December 29, 2023, 06:08:56 PM »

Hmm, I am going over my EVE_commands.c to add the final few missing function briefs that I started to add earlier.
And I came across CMD_REGREAD again.
After some consideration I decided to comment out my implementation like I already did with CMD_MEMWRITE as
I still can not come up with any real use for these - at least not how I implemented these, following the pattern I implemented
other functions that "return" values using the coprocessor.

While doing a CMD_CALLLIST, CMD_REGREAD is the only way to read a register. Similar to CMD_MEMWRITE.


Okay, but for what purpose exactly?
Using CMD_REGREAD in a snippet in RAM_G at least would make it easier to find the address that CMD_REGREAD wrote to.
Logged