Show Posts
Pages: [1] 2 3 ... 8
1  Products / Arduino Due / Re: Analog I/O Pins and ADC Sampling Frequency on: May 02, 2013, 02:58:44 pm
I'm a bit lost inbetween the arduino standard calls and what the DUE is or does,
but I learned that that MCK/2 and prescaler determine the speed of the ADC processing.
given that (clock) speed, taking a sample takes a few clock cycles.

but what determines the sampling timing is what the datasheet calls a trigger.
the trigger can be an external signal or e.g. a timer.

I have not yet gotten that to work yet, however.
If / when I do, I'll report. but I'm following the datasheet, not the arduino calls, so the code is extensive.

2  Products / Arduino Due / Re: Makefile for the Due on: April 27, 2013, 02:41:36 pm
maybe a clue :
I noticed that if I used Serial.println() in an include file, I needed to add
#include <Arduino.h> in that include file

try that for your main sketch, I suspect the IDE does add this behind the scenes.
but the makefile does not (as far as I can read that makefile, I'm no guru..)

3  Products / Arduino Due / dac/adc/usb example might be interesting read on: April 22, 2013, 03:52:06 pm
I found an example "sketch" for a sam3s,
but I feel the code is instructive for the Due as well.
I do not expect this to run on a  Due.

it shows the dac and adc being driven by a timer, and consuming/producing
arrays of data by using the PMC dma.
for me this solved how to run DAC and ADC in parallel.
just use the zip file, the separate pdf is the wrong one.
4  Products / Arduino Due / Re: Timer Interrupts on Due on: April 21, 2013, 04:14:26 pm
   StartTimer starts the timer. this function needs to be called once.
   after Starttimer is finished, the (hardware) timer keeps running on it's own, without any need for code.
   the timer counts up to a certain value, then generates an interrupt, starts with 0 and continues counting.

   TC3_handler is called each time the interrupt of Timer/Counter TC3 (=timer 1 channel 0) is generated by the timer.
   "TC3_handler"  is a pre-determined functionname just like "setup" and "loop"
   because TC3_handler is called for each interrupt, it is called as often as the timer hits that "certain value".
   The lower that value the more often the TC3_handler is executed.

Read the datasheet paragraph 37.7.11, fields WAVE, WAVSEL, TCCLKS. TC_configure just sets bits in the TC_CMR register that belongs to TC3 (= Timer 1 channel 0 )
        uint32_t rc = VARIANT_MCK/128/frequency; <---------- is VARIANT_MCK the frequency of arduino DUE(84MHz)? What does rc do?
Serial.Println(VARIANT_MCK,DEC) will enlighten. spoiler : yes
rc is the value the timer counts towards. it is that "certain value" I mentioned above.

        TC_SetRA(tc, channel, rc/2); //50% high, 50% low<----sets the duty cycle?
yes, see datasheet, for instance.
        TC_SetRC(tc, channel, rc);<---------- what is this line for?
it sets the value the timer counts towards. so it defines the frequency of the interrupts generated by the timer

        TC_Start(tc, channel);<---------------enables PWM? How does it work?
no, it starts the timer. the timer begins incrementing now.

        tc->TC_CHANNEL[channel].TC_IER=TC_IER_CPCS;<----------What does this line do?
I'm not sure but I think it sets the flag that specifies an interrupt is desired when timer = rc. IER = interrupt Enable Register

        tc->TC_CHANNEL[channel].TC_IDR=~TC_IER_CPCS;<--------What does this line do?
IDR = interrupt disable register, all other interrupt-types supported by  TC3 are disabled and will not occur.  

        NVIC_EnableIRQ(irq); <-----enables interrupt?
yes. it is the overall enabler, allowing interrupts to be generated by TC3.

5  Products / Arduino Due / Re: Arduino Due and 6DOF Accel/Gyro on: April 20, 2013, 01:21:56 pm
I have not tried your code, but a common problem is that
the type "int" is 4 bytes large, not 2 as on the uno (i do not know about the mega).

try using int16_t as a type, which is a 2 byte integer and see if things improve.

furthermore, are you sure the wire library is reported to work on the Due ?  

good luck.

<edit> because I have access to secret and undocumented tools,
like the mythical "search button" and "google" I was able to find this post :,158526.0.html
so it seems wire might have problems running on the due...
6  Products / Arduino Due / Re: linking with libarm_cortexM3l_math.a ? on: April 14, 2013, 11:30:10 am
Good links deserve plugging :
this link is about the only one I found that goes into any detail on the DUE ADC capabilities and settings
7  Products / Arduino Due / Re: linking with libarm_cortexM3l_math.a ? on: April 14, 2013, 06:43:04 am
Nice to hear the post has been useful.

I'm making good progress attaching a mic, sampling it and displaying the FFT on a simple 128x64 glcd.
this requires use of the ADC, use of the DMA (pdc), the dsp library and U8glib. and a lot of large arrays.
but it still fits.

I created my own constants to refer to the registers, just to be sure to understand the datasheet

the DMA is freerunning, the sampling rate controlled by the prescaler value.
when needed I ask the PDC to get an array worth of ADC data, then busy-wait for the array to be filled.
after that FFT and display.  

I am confused by the large amount of clocks in the system. it is correct to assume MCK is 4 Mhz in the DUE ?
does anybody know for sure ?
I do see FFT output, but relating it to frequencies is out of my league and currently done by running
the baudline (great piece of software !) tone generator at a known frequency in my PC.

current code (as an example, quite possibly of "how not to program"..) : see attachment

8  Using Arduino / Displays / Re: U8glib: Graphics Lib for LCDs and OLEDs on: April 06, 2013, 08:21:37 am
I got a specific ST7565 board to work on the DUE, but i did not know this thread yet,
it is posted here :,158709.msg1188374.html#msg1188374

including details on wiring it up (and a few tweaks).

9  Products / Arduino Due / U8glib works with some effort on GLCD on: April 05, 2013, 05:04:38 pm
Hi all,

I got this Graphics Board
to work with arduino Due.

Since it was not totally clear to me, I thought it better to document it here.

I used the u8glib library because it was reported to work on the DUE.

I connected
AIO1 of the LCD (SID) to pin 11 of the DUE
DIO1 of the LCD (SCLK) to pin 13 of the DUE
AIO4 of the LCD (A0) to pin 9 of the DUE
DIO4 of the LCD (RST) to pin 12 of the DUE

I connected the DUE 3.3v pin to PWR1 of the LCD
and one of the DUE gnd pins to GND1 of the LCD

u8g wants to bring signal CS to the LCD, but this one is not available on the graphics board.
RST is optional according to u8g, but it is required to make the graphics board function.

in u8g I choose DOGM128 as the driver for the LCD, and added pin 12 (RST) at the end.
" U8GLIB_DOGM128 u8g(13, 11, 10, 9, 12); "

lastly, it proved necessary to tweak the contrast.
in example GraphicsTest I added
" u8g.setContrast(50);" in the setup routine.

I also removed the statements
" //pinMode(13, OUTPUT);
//digitalWrite(13, HIGH); "
from the setup routine as they messed up the state of the lcd.

I would have expected that you needed to configure the used pins
before using them on the DUE, but it proved not necessary.

<edit> more information about u8glib in the display section !
10  Products / Arduino Due / Re: data type sizes on: April 04, 2013, 02:01:59 pm
Thanks for your help !

I guess the uint32_t and it's kin are the new style of how to code.
worked for me (without needing to use an include file)

Still, there is something fishy in that PDC / DMA.
The DMA can transfer 1, 2 or 4 byte chunks, according to the datasheet,
but it is not clear when it is using what format.
If someone knows where i should look for that nugget of knowledge in the datasheet,
please let me know.

11  Products / Arduino Due / data type sizes on: April 03, 2013, 04:37:13 pm
Hi all,

   I'm a bit miffed about the data type changes between Uno and Due.

   I'm playing with low level ADC and DAC control via PDC in a Due.
   it seems the PDC transfers data in 16-bit chunks.
   however, Int is 4 bytes in Due, as opposed to 2 in Uno.
   sizeof(short) is reported to be two bytes but using shorts creates strange
   issues when declaring the array.

   what do I do to create an array of 1024 16-bit-unsigned values in a DUE ?
12  Products / Arduino Due / Re: Help with ADC triggered by timer interrupt on: April 02, 2013, 03:53:46 pm
I think Iḿ missing a statement like

for the ADC.

13  Products / Arduino Due / Re: Just bought a DUE..... on: March 19, 2013, 02:37:51 pm
serious DSP,
addressing large memories,
making sense of the interrupt and DMA system,
libraries for DAC and ADC,
robotics  (with lots of sin(), tan() and cos() etc..),

and everything employing a USB connection

but first: RTFM, it's big...

14  Products / Arduino Due / Re: Sampling audio + exporting to some audible format on: March 15, 2013, 05:05:57 pm
let me google that for you :
15  Products / Arduino Due / Re: Implementing FFT on the DUE on: March 10, 2013, 08:37:18 am
While I can certainly recommend the code of arduinoos,
I got another library to work on the due.
It might be another possibility
have a look here :
Pages: [1] 2 3 ... 8