Routing pll5 to an output pin on teensy 4.1

Hi,

this outputs your desired frequency:
Code:
//(c) Frank B
//
// - Configures Video PLL to output 25.175MHz via I2S on PIN23 - 
// 

#define PADCONFIG ((0 << 0) | (4 << 3) | (0 << 6)) //Pg 622 Reference Manual

#define PLL_DENOMINATOR     960000 // MCUexpresso says 960000 max (thx DM5SG)
#define PLL_NOMINATOR       450000
#define PLL_DIV                  1
#define PLL_DIV_SELECT          31 // this gives PLL = 755250000 Hz
#define PLL_POST_DIV_SELECT      2 //                = 377625000 Hz
#define I2S_PRED                 3 //                = 125875000 Hz
#define I2S_PODF                 5 //                =  25175000 Hz

const uint8_t translate_pll_post_div[] =  { 2, 1, 0, 0 };
const uint8_t translate_pll_video_div[] = { 0, 1, 0, 3 };

void setup() {
  Serial.begin(9600);

  //Setup PLL Divisiors:
  CCM_ANALOG_PLL_VIDEO = CCM_ANALOG_PLL_VIDEO_BYPASS | CCM_ANALOG_PLL_VIDEO_ENABLE
                          |  CCM_ANALOG_PLL_VIDEO_POST_DIV_SELECT(translate_pll_post_div[PLL_POST_DIV_SELECT  - 1]) // 0: 1/4; 1: 1/2; 2: 1/1
                         | CCM_ANALOG_PLL_VIDEO_DIV_SELECT(PLL_DIV_SELECT);
  CCM_ANALOG_MISC2 = (CCM_ANALOG_MISC2 & ~(CCM_ANALOG_MISC2_VIDEO_DIV(3)))
                     | CCM_ANALOG_MISC2_VIDEO_DIV(translate_pll_video_div[PLL_DIV - 1]);

  //Setup PLL:
  CCM_ANALOG_PLL_VIDEO_NUM   = PLL_NOMINATOR;
  CCM_ANALOG_PLL_VIDEO_DENOM = PLL_DENOMINATOR;
  CCM_ANALOG_PLL_VIDEO_CLR = CCM_ANALOG_PLL_VIDEO_POWERDOWN;//Switch PLL on
  
  //Wait for PLL Lock:
  while (!(CCM_ANALOG_PLL_VIDEO & CCM_ANALOG_PLL_VIDEO_LOCK)) {;};
  
  //Disable PLL Bypass:
  CCM_ANALOG_PLL_VIDEO_CLR = CCM_ANALOG_PLL_VIDEO_BYPASS;//Disable Bypass

  //Setup I2S:
  CCM_CCGR5 |= CCM_CCGR5_SAI1(CCM_CCGR_ON);
  CCM_CSCMR1 = (CCM_CSCMR1 & ~(CCM_CSCMR1_SAI1_CLK_SEL_MASK))
               | CCM_CSCMR1_SAI1_CLK_SEL(1); // &0x03 // (0,1,2): PLL3PFD0, PLL5, PLL4
  CCM_CS1CDR = (CCM_CS1CDR & ~(CCM_CS1CDR_SAI1_CLK_PRED_MASK | CCM_CS1CDR_SAI1_CLK_PODF_MASK))
               | CCM_CS1CDR_SAI1_CLK_PRED(I2S_PRED - 1) // &0x07
               | CCM_CS1CDR_SAI1_CLK_PODF(I2S_PODF - 1); // &0x3f

  // Select MCLK:
  IOMUXC_GPR_GPR1 = (IOMUXC_GPR_GPR1 & ~(IOMUXC_GPR_GPR1_SAI1_MCLK1_SEL_MASK))
                    | (IOMUXC_GPR_GPR1_SAI1_MCLK_DIR | IOMUXC_GPR_GPR1_SAI1_MCLK1_SEL(0));
  I2S1_TMR = 0;
  I2S1_TCR2 = I2S_TCR2_MSEL(1);

  //Setup Pin:
  CORE_PIN23_CONFIG = 3;
  CORE_PIN23_PADCONFIG = PADCONFIG;

}

void loop() {}

Your FPGA just needs to read the VGA pins with this clock? I hope the VGA runs with the video pll?
Perhaps you need to adjust the divisors to match the ones of the VGA lib.

I hope you get it running - I spent some time to write this code for you ;-)
 
Hi,

this outputs your desired frequency:

...

Your FPGA just needs to read the VGA pins with this clock? I hope the VGA runs with the video pll?
Perhaps you need to adjust the divisors to match the ones of the VGA lib.

I hope you get it running - I spent some time to write this code for you ;-)

Are you kidding? I was so excited about this that I desoldered my whole protoboard to expose the best multi-region, clock-capable pin!

Fingers crossed!

Jonathan
 
Jonathan,

i have an other idea...
How much RAM is in your FPGA?
Couldn't you emulate a std graphics chip like ILI9341.. I mean:
High speed SPI interface (>30MHz, the more the better) -> FPGA RAM -> FPGA generates all HDMI or VGA signals itself?
By emulating a std lcd graphics chip (they all are more or les the same..) we would not need a special driver.. and can just use the ILI driver :)
AND it would work with other MCU, too without having to write a driver... like ESP32, other Arduinos, STM, etc...

p.s. probably a common driver with a better resolution... ;) 640x480 ... but the more pixels, the "slower" is SPI. A later version could probably have the basic graphics privimitives for lines or to fill areas..
 
Last edited:
Jonathan,

i have an other idea...
How much RAM is in your FPGA?
Couldn't you emulate a std graphics chip like ILI9341.. I mean:
High speed SPI interface (>30MHz, the more the better) -> FPGA RAM -> FPGA generates all HDMI or VGA signals itself?
By emulating a std lcd graphics chip (they all are more or les the same..) we would not need a special driver.. and can just use the ILI driver :)
AND it would work with other MCU, too without having to write a driver... like ESP32, other Arduinos, STM, etc...

p.s. probably a common driver with a better resolution... ;) 640x480 ... but the more pixels, the "slower" is SPI. A later version could probably have the basic graphics privimitives for lines or to fill areas..

Absolutely! Any of those things are doable. I'm often surprised at the fact that many people who program mcus don't dabble more in programable logic (and the other way 'round). https://forum.pjrc.com/threads/68310-Idea-for-an-Arduino-Vidor-4000-Slayer!?highlight=vidor

But, I digress ;)

I can't wait to get home later and try out your code! To be continued... :cool:
 
Absolutely! Any of those things are doable. I'm often surprised at the fact that many people who program mcus don't dabble more in programable logic (and the other way 'round). https://forum.pjrc.com/threads/68310-Idea-for-an-Arduino-Vidor-4000-Slayer!?highlight=vidor

But, I digress ;)

I can't wait to get home later and try out your code! To be continued... :cool:

Are there beginer friendly resources..links...tutorials (please NO videos)?
Would you help me a bit with the first steps?
Is there a beginner friendly (and not too expensive) FPGA board with enough RAM that would be able to output HDMI or VGA?
I'm a bit bored of microcontrollers...
 
Are there beginer friendly resources..links...tutorials (please NO videos)?
Would you help me a bit with the first steps?
Is there a beginner friendly (and not too expensive) FPGA board with enough RAM that would be able to output HDMI or VGA?
I'm a bit bored of microcontrollers...

Happily - try this: https://digilent.com/shop/basys-3-artix-7-fpga-trainer-board-recommended-for-introductory-users/

Xilinx is my personal preference, and the Basys3 is a great board to learn on. It's a powerful enough starter board to be useful, and it will have you up and running in no time. VGA output is built-in, as are a whole bunch of other goodies you'll love to tinker with.

As for language, I suggest Verilog to start with. https://www.amazon.com/Programming-FPGAs-Getting-Started-Verilog-ebook/dp/B01M0F1L5G

Programming FPGAs: Getting Started with Verilog by Simon Monk. It's a little dated, but he makes things really easy to understand. All the software you will need is free.

Whatever else I can do, just ask!

Jon
 
Hi,

this outputs your desired frequency:

...

Your FPGA just needs to read the VGA pins with this clock? I hope the VGA runs with the video pll?
Perhaps you need to adjust the divisors to match the ones of the VGA lib.

I hope you get it running - I spent some time to write this code for you ;-)

Okay, now trying to get it up and running...
 
Are there beginer friendly resources..links...tutorials (please NO videos)?
Would you help me a bit with the first steps?
Is there a beginner friendly (and not too expensive) FPGA board with enough RAM that would be able to output HDMI or VGA?
I'm a bit bored of microcontrollers...

Still working on it - all is well on the teensy side, though. I'm having issues on the FPGA side. I may take my own advice and switch to an Artix-7-based device :D

Jon
 
p.s. probably a common driver with a better resolution... ;) 640x480 ... but the more pixels, the "slower" is SPI. A later version could probably have the basic graphics privimitives for lines or to fill areas..

Hey, @Frank B , how is everything going? Haven't heard from you for a while. J
 
I'm still undecided if I'll look at FPGAs or if I'll do something completely different. Thank you for the links! The board looks good. I am not sure what I could use it for. I just can't think of anything...
 
I'm still undecided if I'll look at FPGAs or if I'll do something completely different. Thank you for the links! The board looks good. I am not sure what I could use it for. I just can't think of anything...

Well, being familiar with your other work, I'm sure you'll come up with something; you've got the creative spirit :D

Maybe, just to learn, take something (simple) you would do with a MCU, and make it into a FPGA project. I mean, that board has seven-segment displays, switches, LEDs - start by blinking a light or two and then go from there. The only thing that might take some time to get used to, well, amongst other things, is the fact that everything can happen in parallel.

Jonathan
 
Ok... you got me...

I ordered this one:https://digilent.com/reference/programmable-logic/arty-a7/start
Is that OK? :)

Still not sure if I ever need it.. but I like that is has 256MB Ram.

Absolutely - I have a few on my desk right now :D

I'm hoping you got the A7-100T version. That is a fantastic piece of hardware, beginner or otherwise.

Make sure you do the tutorials on the reference page you sent me; that will get you into the workflow. Once you do that, you'll see how you can come full circle with the Microblaze soft processors (as a learning exercise) - designing your own mcu with custom peripheral hardware of your own design and then programing it in embedded C.
 
Absolutely - I have a few on my desk right now :D

I'm hoping you got the A7-100T version. That is a fantastic piece of hardware, beginner or otherwise.

Make sure you do the tutorials on the reference page you sent me; that will get you into the workflow. Once you do that, you'll see how you can come full circle with the Microblaze soft processors (as a learning exercise) - designing your own mcu with custom peripheral hardware of your own design and then programing it in embedded C.

It is the smaller one, the A7-35 version. It will arrive Monday.
Oh my... well I installed the 150GB!! IDE...
Tried the Blinky tutorial. Seems to be for a older version. Screenshots do not fit...

Got a warning:

Neither the CFGBVS nor CONFIG_VOLTAGE voltage property is set in the current_design. Configuration bank voltage select (CFGBVS) must be set to VCCO or GND, and CONFIG_VOLTAGE must be set to the correct configuration voltage, in order to determine the I/O voltage support for the pins in bank 0. It is suggested to specify these either using the 'Edit Device Properties' function in the GUI or directly in the XDC file using the following syntax:

set_property CFGBVS value1 [current_design]
#where value1 is either VCCO or GND

set_property CONFIG_VOLTAGE value2 [current_design]
#where value2 is the voltage provided to configuration bank 0

Refer to the device configuration user guide for more information.

Why isn't that setting in the XDC file, and what do I have to do? :) Is it VCCO or GND?
 
It is the smaller one, the A7-35 version. It will arrive Monday.
Oh my... well I installed the 150GB!! IDE...
Tried the Blinky tutorial. Seems to be for a older version. Screenshots do not fit...

Got a warning:



Why isn't that setting in the XDC file, and what do I have to do? :) Is it VCCO or GND?

That's fine - the Artix 7 35T is a lot of board! The Arty version is the same chip as the Basys3, but it makes much more of the IO mobile and available. I'm guessing that drove your decision.

Which specific tutorial are you trying? When Digilent uploads new ones, they often don't delete the old ones. So, be sure you're using the most recent. You can fix those settings in the Constraints Wizard, but you're getting way ahead of yourself :p

Do this first: https://digilent.com/reference/programmable-logic/guides/installing-vivado-and-vitis

After you set up the board files, and download the most updated XDCs, you shouldn't get that error anymore.
 
@Frank B ,

Got a question for you - your mcu expertise... QuadSpi Flash! I read your code, as I installed 8mb psram and a flash chip on one of my Teensy 4.1s. The PSRAM passes the test. With the flash, it finds it and asks me if I want to format (y). I do so, and it again finds the flash. Then it says that it's mounting it. Then it resets and asks me, again, to init within 6 seconds. And then it goes round and round in an endless loop. Any ideas?
 
@Frank B ,

Got a question for you - your mcu expertise... QuadSpi Flash! I read your code, as I installed 8mb psram and a flash chip on one of my Teensy 4.1s. The PSRAM passes the test. With the flash, it finds it and asks me if I want to format (y). I do so, and it again finds the flash. Then it says that it's mounting it. Then it resets and asks me, again, to init within 6 seconds. And then it goes round and round in an endless loop. Any ideas?

Hi,
no....sorry... for this stuff, better ask Kurt, Michael or Tim. They do a lot with flash, littlsfs etc. I had problems with a flash, too. Turned out to be a not good soldering.

I try the FPGA blinky again when the board is here.
I tried everything again yesterday and now I get even more warnings... but maybe I've not seen them before.
This stuff is incredible slow (takes 1 minute to synth. the one-liner "blinky"? ) and unclear.. have to do more with it, to get used to it... :)
 
Hi,
no....sorry... for this stuff, better ask Kurt, Michael or Tim. They do a lot with flash, littlsfs etc. I had problems with a flash, too. Turned out to be a not good soldering.

I try the FPGA blinky again when the board is here.
I tried everything again yesterday and now I get even more warnings... but maybe I've not seen them before.
This stuff is incredible slow (takes 1 minute to synth. the one-liner "blinky"? ) and unclear.. have to do more with it, to get used to it... :)

Oh, warnings. You'll always have a lot of those - yellow and orange. Just take note of the orange ones, but unless you get a red error, you're fine. The rule checks are just overly sensitive. Don't worry about the yellows and oranges, especially if you're just doing a tutorial.
 
Back
Top