ADC on an FPGA, Finally got it working.

Thread Starter

tindel

Joined Sep 16, 2012
817
The last couple of days I've been working on an ADC on an FPGA. I was trying to get the data before it was automatically sent to the DMA.

Of course the whole thing needs to be interrupt driven to keep speeds up... I start by looking through manuals, user guides, datasheets, app notes, etc. I pretty quickly find the interrupt enable that I ultimately need to use, but they don't describe how to use it at all. I play around with the FPGA software for a while and finally put some things together so I know the actual pins I'm looking for, but there's one problem it's not available to the fabric, only the microcontroller - so I start thinking what I want to do may not even be possible. More digging - I find a way to get the microcontroller interrupts out to the fabric. The users guide says that I also have to enable a couple of interrupts, but only talks about one of the two enable bit registers. Ugh! More digging and testing.... sure enough the interrupt isn't firing with the one enable bit enabled, but I can see the ADC working with a simple trimpot into the ADC channel and PWM to indicate the output voltage. I know the ADC is working, but why isn't the interrupt firing? More digging - nothing is obvious.... more digging nothing is still obvious.... repeat a bit longer... getting frustrated... finally I get a clue. An old program I have is also using interrupts and I can see where it's second enable is located, and while it's not exactly the same as mine; I clue into where the second interrupt enable (and clear) are at in memory space.

15 minutes latter, I modify my FSM a little bit, and it's working - at least on the surface - needs a lot more testing to be sure. Only took me two days to put all the pieces together.

It always feels good when you finally get it working, I'm sure many of you know the feeling.
 

atferrari

Joined Jan 6, 2004
4,476
The last couple of days I've been working on an ADC on an FPGA. I was trying to get the data before it was automatically sent to the DMA.

Of course the whole thing needs to be interrupt driven to keep speeds up... I start by looking through manuals, user guides, datasheets, app notes, etc. I pretty quickly find the interrupt enable that I ultimately need to use, but they don't describe how to use it at all. I play around with the FPGA software for a while and finally put some things together so I know the actual pins I'm looking for, but there's one problem it's not available to the fabric, only the microcontroller - so I start thinking what I want to do may not even be possible. More digging - I find a way to get the microcontroller interrupts out to the fabric. The users guide says that I also have to enable a couple of interrupts, but only talks about one of the two enable bit registers. Ugh! More digging and testing.... sure enough the interrupt isn't firing with the one enable bit enabled, but I can see the ADC working with a simple trimpot into the ADC channel and PWM to indicate the output voltage. I know the ADC is working, but why isn't the interrupt firing? More digging - nothing is obvious.... more digging nothing is still obvious.... repeat a bit longer... getting frustrated... finally I get a clue. An old program I have is also using interrupts and I can see where it's second enable is located, and while it's not exactly the same as mine; I clue into where the second interrupt enable (and clear) are at in memory space.

15 minutes latter, I modify my FSM a little bit, and it's working - at least on the surface - needs a lot more testing to be sure. Only took me two days to put all the pieces together.

It always feels good when you finally get it working, I'm sure many of you know the feeling.
Would you mind showing the simplest possible block diagram? Just to follow your comments.
 

strantor

Joined Oct 3, 2010
5,696
Learning things this way takes longer but the lesson lasts longer too. Most of the things that are firmly lodged in my memory are things that took days of bashing my head against something that should've only taken a few minutes.
 
Top