Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for BUS_WIDTH = 16 #5

Open
rjonkman opened this issue Sep 23, 2023 · 9 comments
Open

Fix for BUS_WIDTH = 16 #5

rjonkman opened this issue Sep 23, 2023 · 9 comments

Comments

@rjonkman
Copy link

uint8_t beats = SHIFTNUM * BEATS_PER_SHIFTER;

I had to change this to:

   #if BUS_WIDTH == 16
    uint8_t beats = SHIFTNUM * BEATS_PER_SHIFTER / 2;
    #else
    uint8_t beats = SHIFTNUM * BEATS_PER_SHIFTER;
    #endif
@rjonkman
Copy link
Author

rjonkman commented Oct 1, 2023

This doesn't seem to be a complete fix. It does cause the correct pixel to be lit on the screen, but colors are not correct. They seem to be inverted perhaps? For example, a pixel that should be green is red.

Is this definition correct? I'm not entirely sure what it's used for, but If we are using a 16 bit bus mode, wouldn't it be sending two bytes per beat?
#define BYTES_PER_BEAT (sizeof(uint8_t))

@rjonkman
Copy link
Author

rjonkman commented Oct 1, 2023

To get the colors right, a had to replace the 16bit bytes swap in flexIRQ_Callback() with a 32bit swap. I imagine this should be included even in your library for a 8bit interface.

 p->SHIFTBUFBYS[i] = ((((data) & 0xff000000) >> 24) |
                    (((data) & 0x00ff0000) >> 8) |
                    (((data) & 0x0000ff00) << 8) |
                    (((data) & 0x000000ff) << 24));

@rjonkman
Copy link
Author

rjonkman commented Oct 1, 2023

That last issue I'm having with your code is that the aync methods are running too fast , even as the lowest baud setting. Is there any way to slow everything down some more?

@david-res
Copy link
Owner

To get the colors right, a had to replace the 16bit bytes swap in flexIRQ_Callback() with a 32bit swap. I imagine this should be included even in your library for a 8bit interface.

 p->SHIFTBUFBYS[i] = ((((data) & 0xff000000) >> 24) |
                    (((data) & 0x00ff0000) >> 8) |
                    (((data) & 0x0000ff00) << 8) |
                    (((data) & 0x000000ff) << 24));

SHIFTBUFBYS does a byte swap
Try changing to SHIFTBUF

That swaps the bytes around

You can find more info here on the various methods:
https://community.nxp.com/t5/Kinetis-Microcontrollers/Understanding-FlexIO/ta-p/1115419

@david-res
Copy link
Owner

That last issue I'm having with your code is that the aync methods are running too fast , even as the lowest baud setting. Is there any way to slow everything down some more?

You can try to lower the FlexIO clock speed by dividing down the source clock in the FlexIO_init function
IIRC it's running at 240Mhz at the moment. You can go down to 120/6030 etc by increasing the divider value

It's important to note that the baud rate of the bus is derived from the FlexIO clock speed, so if you were running at 20Mhz and you lower the FlexIO clock speed to 120 from 240, your new bus speed would be half of 20Mhz..

@rjonkman
Copy link
Author

rjonkman commented Oct 1, 2023

Hi,

Thanks, SHIFTBUF works perfectly on the RA9975 without any byte swapping. Unfortunately, as I go over the finer details of the code, if I'm already at the lowest baud setting, having the FlexIO clock is not going to help.

I can get it stable-ish by reducing the number of shifters and adding a microsecond delay inside the interupt callback, but I still end up with some pixels that don't get lit properly, and because I'm mirroring the the screen pixels in EXTMEM and only updating the ones that change, some of those pixels just never get drawn properly. So I'm stuck using the blocking methods to push pixels--such a shame. I pretty much only need the device to handle the display. I have a few other time sensitive things I need to do, but I should be able to put them into their own interrupt routines.

@david-res
Copy link
Owner

I have a possible solution
Use a boolean to determine if the interrupt has triggered or not.
In your main loop use a delay without delay loop to check if the bool is true - run the IRQ routine then set the bool back to false.
You can set the time between checks at your desired intervals.

@rjonkman
Copy link
Author

rjonkman commented Oct 1, 2023 via email

@rjonkman
Copy link
Author

rjonkman commented Oct 2, 2023

Couldn't make any progress by overclocking. There must be some other limit to how fast the RA8875 can process pixels. I restored to progressively drawing to the screen line by line each time through the loop(). It works great and I can tend to other other small tasks while the screen is in the process of being drawn.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants