I am a mechanical engineering grad student using an Alvidi dev board with a XMEGA128A1U and external SDRAM (link). I am using the system to control a motor along with reading three encoders.
I have the system working fine and all, but I would like to add a data logging feature. Here is how I'd like the system to work:
1) Turn on and wait for serial command from computer to start.
2) Commence control routine. For every cycle, store 4 integer variables into memory.
3) Run until "stop time" is reached.
4) When stopped, send data to computer for analysis
The data is to look like the following table:
|DAC_OUT||Encoder 1||Encoder 2||Encoder 3|
Here are my assumptions, i need to store the 4 integer variables in memory. My issue is that I don't really get address tables, block sizes, and all that. I played around with one of the EBI examples in AVR1312 and it does what it's supposed to, but after reading and reading and reading, I'm not getting how I set up the SDRAM registers for my needs.
I'd like to write a loop that iterates through the memory addresses and sends it via usart to my computer. So I guess here are my questions based on the above data table:
Assuming: DAC_OUT is an unsigned integer (values = 0 to 4095). Encoder values are signed integers (values = -7000 to +7000).
1) As a sanity check, can you please confirm that the values above are type short int and take up 2 bytes of memory? If so, that means that I need 8 bytes of memory (2 bytes * 4 short int variables) for every clock cycle?
2) If the above is true, how big of an "Address Space" do I need? If I want to iterate through the addresses, does that mean that if I set the "Address Space" to 8 bytes, that I can achieve what I want neatly???
3) I am utterly confused about SDRAM row bits and SDRAM column bits. Can you please clarify as to what I need to set them to?
4) I am running the routine in a Timer Overflow ISR clocked at 226 Hz -- this is how my professor says it needs to achieved. The CPU is set at 32 MHz. What considerations should I make for delays???
5) The example that I was playing with has a defined function (__far_mem_read(addr)) which uses assembly language to retrieve the data from the memory address. What should the function in C look like to retrieve the data from the memory address?
6) And finally, I really found the USART tutorials from FourWalledCubicles VERY helpful. Is there an equivalent out there for EBI?
Any considerations that I am not bringing up would be appreciated. Also, if you could kindly list your recommendations as bullet points, that would be great for me and for anybody else who will read this post.