[Closed:Faulty] Clock works intermittently - Cyclone IV board from Aliexpress - Page 1
Forum section: electronics / general

author: plastygrove
author_rank: Contributor
timestamp: May 16, 2020, 02:17:11 am
content: Hi all - This may be a noob question.I am usingALTERA Cyclone IV EP4CE6 FPGAboard from Aliexpress and am running into strange issues with the clock. The board has a 50 MHz oscillator which is connected to pin 23 of the FPGA.I have a simple blinking code that I'm trying to run and here is what is happening.Day 1 - Blink doesn't work, no matter what I try. Things I tried:- Reduce the counter to 2 bits and use a push button switch as a fake clock. It works perfectly.- Change IOStandard of the pins from 2.5V (default) to 3.0V and 3.3V for both (LVTTL and LVCMOS).- Unplug the USB blaster and reconnect and re-flash. Turn the board off and on.- Program using active serial onto EEPROM and power the board off and on.Day 2 - I just plug it in and it works. Dont' know why. I leave it on the whole day and even modify the code a bit and flash it again. It just works. I turn it off and go to bed.Day 3 - Stops working again. Exact same code from yesterday. Tried everything from day 1 again and doesn't work.Hereis the verilog code.Hereis the constraints file.Hereis the schematic of the board.Question- Is the clock or some connection damaged? Should I just throw this board and use a different one? Or am I doing something fundamentally wrong?I'm using Quartus Prime 19.1 and the chip is FPGA Cyclone IV series EP4CE6E22C8N

author: hamster_nz
author_rank: Super Contributor
timestamp: May 16, 2020, 04:27:12 am
content: Where's you pin mapping/binding? Can't see it in the constraint (but I am looking at this on my phone....)

author: plastygrove
author_rank: Contributor
timestamp: May 16, 2020, 05:17:03 am
content: Sorry, do I need to specify all the pins in the constraint file? I thought it was only needed for the clock.I did the pin assignment using pin planner, here's the screenshot:

author: Bassman59
author_rank: Super Contributor
timestamp: May 16, 2020, 06:14:56 am
content: Quote from: plastygrove on May 16, 2020, 05:17:03 amYes, of course. Every pin in the design needs a placement constraint -- otherwise how would the tools know to choose the pins connected to your LEDs and which one is your clock?The I/O standard must match the bank voltage supply. You can't just arbitrarily choose it. LVTTL vs CMOS sets the input logic thresholds but it should match the driving source or the output.Use an oscilloscope to verify that the oscillator works and that the output pins are toggling. LEDs need to be toggled at a "slow" rate, otherwise you won't see them turn off and on.

author: plastygrove
author_rank: Contributor
timestamp: May 16, 2020, 06:31:22 am
content: Quote from: Bassman59 on May 16, 2020, 06:14:56 amMy understanding was that in quartus that's done through the pin planner and the constraints file (Section 3 in this pdf) is only needed for the timing analyzer. Please correct me if I'm wrong. Previously, when it worked, I didn't even have the constraints file.Quote from: Bassman59 on May 16, 2020, 06:14:56 amDocumentation is a bit sparse, so I'm not sure which one I should use here. The last time it worked was using 2.5V which is the default.Quote from: Bassman59 on May 16, 2020, 06:14:56 amThat's not an option unfortunately with the lockdown.

author: Bassman59
author_rank: Super Contributor
timestamp: May 16, 2020, 04:25:52 pm
content: Quote from: plastygrove on May 16, 2020, 06:31:22 amThe pin planner ultimately writes a constraint file.You need a placement constraint always, whether it’s done in the text file or through the planner shouldn’t matter.You also need a timing (period) constraint to ensure that the design works at the intended frequency. Which is to say, always.Quote from: plastygrove on May 16, 2020, 06:31:22 amThe schematic tells you the bank voltage, and hence the pin voltage. Do you have the schematic? If not, bin the thing. As for LVTTL vs CMOS, if you are driving LEDs it should be CMOS. In any case, the output pins swing to the rail subject to load current. And you need to set the output current in the pin planner.Quote from: plastygrove on May 16, 2020, 06:31:22 amThen you’re blind. Sorry I can’t help with that.

author: plastygrove
author_rank: Contributor
timestamp: May 17, 2020, 01:37:35 am
content: Quote from: Bassman59 on May 16, 2020, 04:25:52 pmThis is very helpful thanks. The schematic does have the bank voltage and it shows 3.3V. Unfortunately, that didn't change anything. At this point I'm ready to give up. The board has been in storage for 3 years at least and maybe moisture or something has rendered the oscillator unreliable. Or maybe I am doing something fundamentally wrong with the software stack that is causing this issue. I am hesitant to buy these cheap boards anymore, the possibility of something going wrong seems higher.The reason I really wanted this board to work was because it has a built-in VGA and I was hoping to get some video output eventually. I have aniCEstick boardas well which I was able to get up and running quite reliably quite fast. Downsides of this board though are that it only has 1K logic gates compared to the 6K in the aliexpress board and it only has a serial programmer (no JTAG) which is a bit slower.Thanks much for your help though!

author: Wiljan
author_rank: Regular Contributor
timestamp: May 17, 2020, 05:34:05 am
content: How are you powering the board? Try with an externsl 5v psu instread of usb.Also try making some code reading input sw and some logic to drive leds without any clk and see it that is stable each time you program the board.Next make counter to the leds wit a push button as clk and see if it counts. (It will count wrong due to noise / no debounce)If the above works the osc might be faulty and a scope would be a next step but you could measure the 3v3 and see it is steady and also try to resolder the osc

author: ale500
author_rank: Frequent Contributor
timestamp: May 17, 2020, 06:59:47 am
content: I think that some problems with that board are due to missing decoupling. At least my board, that looks very similar to yours, has one 100 nF on the 3v3 rail only.

author: plastygrove
author_rank: Contributor
timestamp: May 17, 2020, 07:18:13 am
content: Quote from: Wiljan on May 17, 2020, 05:34:05 amThanks for the suggestion. I was powering it with USB. Just tried it with a standalone 5V phone charger and doesn't work.Quote from: Wiljan on May 17, 2020, 05:34:05 amI tried both of these and they work just fine quite reliably. Simple combinational logic works perfectly fine. I even used a push button switch as the clk and it works perfectly fine too (with a 2 bit counter though). The only thing that doesn't work is the actual oscillator.Resoldering will have to wait until the lockdown ends unfortunately.Quote from: ale500 on May 17, 2020, 06:59:47 amIt's possible. I bought this board 3 years ago and never used it. Maybe the latest version of this board doesn't have this issue? Also, can an oscillator be so susceptible to decoupling? Esp if it's powered by the USB from my laptop?

author: Wiljan
author_rank: Regular Contributor
timestamp: May 17, 2020, 07:53:32 am
content: Great to hear the the board and not complete deadYou could try to connect some external "clk" if you have any other board around steal a x Mhz and insert in on a i/o pinor sending 0x55 with a high baudrate to the serial port and use the data pin as clk in the FPGAor connect a PS2 keyboard and keep a key pressed constant and grab the clk form the PS2Guess they are many way you can have some fun even if the internal osc are broken...Try to take a closeup picture of the osc solder joints to see if they do look good... you can try to press a little on the solder joint of the osc and see it it than starts to work (broken solder joint)In the schematic for the board i foundhttps://yadi.sk/d/WWPc2vLC3PWCRpthere seems to be many cap's installed so I doubt that's problem, but sure you board might be a "ripped" clone to keep cost down

author: ebclr
author_rank: Super Contributor
timestamp: May 17, 2020, 09:38:10 am
content: 95% probability that the problem, is in the person behind the board, This kind of board normally comes with some demos, try the demo they will check the board, It's a very basic board have very few things to failDemo code for your boardhttps://drive.google.com/file/d/0B1JMWID3C7KNa1RxM0NzeFIwdUk/view

author: plastygrove
author_rank: Contributor
timestamp: May 17, 2020, 10:54:17 am
content: Quote from: Wiljan on May 17, 2020, 07:53:32 amThese are some excellent ideas. I never thought about hooking it up to an external oscillator! I'm sure I have an Arduino lying around somewhere, should at least give me a 16MHz clock (or thereabouts). Thanks for the suggestion.Quote from: Wiljan on May 17, 2020, 07:53:32 amThis is also a good idea - can't find anything wrong with my naked eye. Poked it around a few times, seems to be placed in quite firmly though. Maybe worth closer examination.Quote from: ebclr on May 17, 2020, 09:38:10 amDefinitely not ruling out the person behind the board. Thanks so much for the demo code, having some difficulty downloading it though (keeps dying with NETWORK_FAILED). I'll get it eventually though and post back if it works!Appreciate all the helpful suggestion!

author: plastygrove
author_rank: Contributor
timestamp: May 17, 2020, 11:30:14 am
content: Tried the sample code and can confirm it doesn't work either. Code is a simple 4-Led blink program (led_twinkle) and uses the same pins that I used. LEDs don't change. Here's a video.EDIT: Just a note, I'm using Quartus Lite 19.1 while the sample code uses Quartus 13. I'm assuming that shouldn't make a difference since it compiles fine, but if not please let me know and I'll download Quartus 13.Also if it helps, here are thecomplete log messageswhen compiling.

author: plastygrove
author_rank: Contributor
timestamp: May 18, 2020, 08:46:52 am
content: I tried it with the Quartus 13 as well and didn't make a difference. I guess safe to say the clock isn't working and I'll just put it back in storage. Maybe can use it at some point with the trick WilJan suggested, but until then I'll just use the icestick. Thanks all for your help and suggestions! It is much appreciated!

author: Ice-Tea
author_rank: Super Contributor
timestamp: May 18, 2020, 08:59:27 am
content: If you have a working Icestick, you can always use an IO there to output a clock and feed it to the Cyclone board

author: plastygrove
author_rank: Contributor
timestamp: May 18, 2020, 10:11:10 am
content: Quote from: Ice-Tea on May 18, 2020, 08:59:27 amYup - the icestick has only 1K logic elements, I'm sure I'll run out pretty quickly if I implement a CPU with VGA controller. That's when I'll probably feed the 12MHz clock on the icestick to the cyclone board. Alternatively, I could also use an arduino board to drive the clock as well.

author: ebclr
author_rank: Super Contributor
timestamp: May 19, 2020, 08:42:19 am
content: I believe that he suggested the ice stick only as a tool to generate the clock for test purposes

author: plastygrove
author_rank: Contributor
timestamp: May 19, 2020, 04:25:05 pm
content: Quote from: ebclr on May 19, 2020, 08:42:19 amFair enough. I tested it using the push button switch and it does work, so pretty confident that it will work with an external clock signal feeding into a pin.

author: asmi
author_rank: Super Contributor
timestamp: May 19, 2020, 04:51:13 pm
content: Quote from: plastygrove on May 19, 2020, 04:25:05 pmI would desolder and replace the clock generator IC on that board. Though I have never seen them fail like that, but they are cheap so - why not?