[Logo] Hempstick Forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
SAM4E Support  XML
Forum Index » Projects
Author Message
Hempstead

[Avatar]

Joined: 11/07/2014 16:17:29
Messages: 56
Offline

The SAM4E support project has begun...

However, I am hitting a problem with the new much more advanced Analog Front End Controller (AFEC) module... I have to rewrite substantial parts of the rtos_adc module in Hempstick to accommodate this new change. Atmel's ASF pulled out a brand new API for the AFEC module and does not support the old universal ADC API on the SAM4E chip.

I suppose this is a good thing... because the new AFEC is quite more advanced than the old ADC interface. It has hardware oversampling and low pass filter! I had to write those in software for the old ADC interface in Hempstick and with the AFEC I don't have to. If the future higher end Atmel SAM chips would all come with this AFEC thing, it would worth my effort to do it now in the Hempstick.... so on we go.

Stay tuned.
Hempstead

[Avatar]

Joined: 11/07/2014 16:17:29
Messages: 56
Offline

Made some significant progress today on the AFEC front. Got the settings going, channels setup,/enabled, the TIOA0 based hardware timer of ADC trigger, and the conversion PDC read buff full interrupt to fire....

Still need to get the handler to move the data out by channel tags, and cancel the interrupt (or that damned int. keeps firing!). I remember if I just read the data or one of the registers, it will cancel the int. We will see if that's still true.

This is PDC thing is Peripheral DMA Controller. It lets us hook up with some peripherals with DMA to move data out of peripheral registers into memory we designate. Avoids banging heads against peripherals directly. Instead of reading ADC data register each time a channel conversion is done. We just let PDC read all channel data out and call us once. Meaning, stop bugging me, go bug PDC, I ain't polling you repeatedly. Note that since PDC is a DMA, there is no CPU used when PDC moves data out of the ADC.


Not only this saves CPU cycles, it also should behave much less time critical n a heavily loaded system. See, if you tell the ADC to do 16 channels conversion. One channel finishes, you get an interrupt. You must move the data out before the next conversion finishes., or you get an overrun. If your MT system is heavily loaded and you let the damned ADC do a million samples per second, and you could not move the data out fast enough, you are screwed with overrun. With PDC, our workload is 16 times less, and there will never be overrun (instead we get PDC buffer overwrite, but we always want the latest axis data anyway!).
Hempstead

[Avatar]

Joined: 11/07/2014 16:17:29
Messages: 56
Offline

The PDC transfer seems to be working now. SAM4E's ADC PDC transfer with tags are 32bit instead of 16bit per channel for SAM4S & SAM3X's. So I had to increase the size of PDC sample and accumulators's size and keep it the same size for older ADCS.

Now, I just have to make sure other parts work, and does not break other boards.
Hempstead

[Avatar]

Joined: 11/07/2014 16:17:29
Messages: 56
Offline

Hit a snag.... The USB is not working.... Got to be some thing about Vbus detect or required pin not enabled or something stupid like that due to new chip having different defaults and stuff like that. Things like that is always very frustrating and time consuming to debug b/c these uCs don't tell you jack.

Very annoying. The chip is so new that even the data sheet is missing the listing of critical USB Id and vbus pin peripheral... Had to search the example code and CMSIS headers.... Didn't find all of them. Grr...

This message was edited 1 time. Last update was at 25/07/2014 17:43:02

cpasset


Joined: 10/10/2014 05:20:53
Messages: 1
Offline

Hi,

I am also working on the SAM4E in order to design a USB device which will require a lot of ADC working altogether, and I currently working on trying to make the PDC and AFEC working altogether. It sounds like you achieved to use these two components efficently in order to have a high rate ADC sampling, would it be possible for you to provide me with some insights on how to implement those two functions ?

For the USB function, I also had some trouble making it work, first : check the clock settings of the board in order to have 48Mhz for the USB.

If I can help you somehow please fell free to aks

regards
Hempstead

[Avatar]

Joined: 11/07/2014 16:17:29
Messages: 56
Offline

cpasset wrote:Hi,

I am also working on the SAM4E in order to design a USB device which will require a lot of ADC working altogether, and I currently working on trying to make the PDC and AFEC working altogether. It sounds like you achieved to use these two components efficently in order to have a high rate ADC sampling, would it be possible for you to provide me with some insights on how to implement those two functions ?

For the USB function, I also had some trouble making it work, first : check the clock settings of the board in order to have 48Mhz for the USB.

If I can help you somehow please fell free to aks

regards


Well, all you have to do for PDC is look at how I do ADC in the Hempstick ADC module. Basically, you just have to load up the PDC's buffer pointers correctly and the hardware does it all, hands free. For AFEC, all I had to do to make it work is a bunch of macro to switch to use the new AFEC API when SAM4E is used and it worked like a charm. Themacros are very nasty. I would have preferred not to use it. But ASF uses a lot of it, unavoidable. But b/c of the non-working USB part, I have not checked in the code yet.

Thanks for the pointer on the clock! I should check that!!!
 
Forum Index » Projects
Go to:   
Powered by JForum 2.1.9 © JForum Team