Show Posts
Pages: [1] 2 3 ... 10
1  Products / Arduino Due / Re: How to connect SD card reader to Arduino DUE - help needed on: September 16, 2014, 02:23:24 pm
You need to use the spi pinheader. The spi is not connected to pin 13, 12, 11 and 10 as on the avr arduinos.
2  Products / Arduino Due / Re: Arduino Due + Digit Shield(nootropic design) library on: September 10, 2014, 02:29:22 pm
It looks like the library uses avr registers. You'll have to find out what the code does, and make a due equivalent.
3  Products / Arduino Due / Re: From Arduino board to an Embedded aplication. on: September 02, 2014, 02:19:42 pm
Thank you Gericom and CrossRoads.
So Gericom, you are saying I could compile my code using Arduino and upload the *.bin file using SAM-BA directly through the built in usb port? That should work?
I think you should be able to upload from within the arduino ide (native port).
4  Products / Arduino Due / Re: From Arduino board to an Embedded aplication. on: September 02, 2014, 01:13:52 pm
You can use the build-in usb port. The chip got a preprogrammed bootloader, which you can use with the arduino ide afaik.
5  Products / Arduino Due / Re: Making use of TC channel 3(TC2) in Atmel studio on: July 17, 2014, 03:42:49 am
You can use TC1 for timer interrupts on sam3x8e, but not for pin related things.
6  Products / Arduino Due / Re: Making use of TC channel 3(TC2) in Atmel studio on: July 16, 2014, 03:08:58 pm
As far as I know, each TC got 3 channels. So 3x3=9 channels total. Take a look at the datasheet.
7  Products / Arduino Due / Re: aruino due board file on: July 14, 2014, 08:54:51 am
I have no board file for you, but my board got also no ic at that place. But my board is more greenish and got a white erase button rather than a black one.
8  Products / Arduino Due / Re: Due support for AVR (atmel) libraries on: July 14, 2014, 07:17:28 am
No, you can not use avr libraries on an arm processor. What you can do to solve this problem, is finding out what function the code uses from the avr library, and make an equivalent function that does work on the due.
9  Products / Arduino Due / Re: aruino due board file on: July 09, 2014, 08:18:47 am
Maybe you should post a better picture first. This one is quite blurry.
10  Products / Arduino Due / Re: Arduino Due digital read speed on: July 06, 2014, 03:45:04 am
@Measureino - Smart idea!  I changed everything to port C, and instead of doing bit manipulations during the sampling process, I am instead doing it after I've collected the number of samples I care about.  So, this code here:

Code:
for(count=0;count<N;count++){
    //sample[count] = get_ADC_2::get_ADC();  //"can't convert get_ADC_2 to "unsigned int" wtf
    PIOC->PIO_ODSR = 0x0;       // write 0 to CLK line (Analog input 11 on Arduino Due used as CLK for ADC)
    //delay(.00015);
    PIOC->PIO_ODSR = 1<<15;  // write 1 to CLK line (Applies 3.3V to ADC)
    c[count] = REG_PIOC_PDSR;
  }

is what i'm working with.  This gives me ~3.4MHz sampling rate max.  seems kind of slow, eh?

@Gericom- Thanks!!  Any idea how fast it can sample?
I have no idea. As I said, you can't control the DMA speed, so you should just try.

Also, you can better use PIOD, since D0-D10 are all available on the due, so you don't have to shift.

Here is that bit of code in ASM (also, not tested):
Code:
noInterrupts();
asm volatile("push r0-r5");
asm volatile("ldr r0,=N");//Change N to the amount of samples you want
asm volatile("mov r1, #0x8000");
asm volatile("ldr r2,=0x400E1238");//REG_PIOC_ODSR
asm volatile("ldr r3,=c");//if you define c as an array, this will be it's address
asm volatile("add r0, r3, lsl #2");//I assume c is a 32 bit array?
asm volatile("mov r4, #0");
asm volatile("1:");
asm volatile("str r4, [r2]");
asm volatile("str r1, [r2]");
asm volatile("ldr r5, [r2, #4]");
asm volatile("str r5, [r3], #4");//I assume c is a 32 bit array?
asm volatile("cmp r0, r3");
asm volatile("bne 1b");
asm volatile("pop r0-r5");
interrupts();
11  Products / Arduino Due / Re: Arduino Due digital read speed on: July 05, 2014, 03:52:30 am

I made some code to make using DMA much simpler. I can post it here if you want.

That'd be awesome!  I'm totally new to the concept of DMA - would you care to provide a brief explanation on how your DMA library works?

Would be much appreciated!

dma.cpp:
Code:
#include <Arduino.h>
#include "dma.h"
void DMA_Init()
{
  REG_PMC_PCER1 = 1<<7;
  REG_DMAC_WPMR = DMAC_WPMR_WPKEY(0x444D4143);//Disable write protection
  REG_DMAC_EN = 1;//Enable
  REG_DMAC_GCFG = 0x00000010;
}
void DMA_SetupTransfer(int channel, void* src, int src_length, int src_width, int src_incr, void* dst, int dst_width, int dst_incr, int flow_control)
{
  REG_DMAC_EBCIDR |= 0x10101 << channel;//Disable Interupts
  *((uint32_t*)(0x400C403C + 0x28 * channel)) = (uint32_t)src;
  *((uint32_t*)(0x400C4040 + 0x28 * channel)) = (uint32_t)dst;
  *((uint32_t*)(0x400C4044 + 0x28 * channel)) = 0;
  *((uint32_t*)(0x400C4048 + 0x28 * channel)) = ((src_length >> src_width) & 0xFFFF) | (6 << 16) | (0 << 20) | ((src_width & 0x3) << 24) | ((dst_width & 0x3) << 28);
  *((uint32_t*)(0x400C404C + 0x28 * channel)) = (0 << 16) | (0 << 20) | ((flow_control & 0x3) << 21) | ((src_incr & 0x3) << 24) | ((dst_incr & 0x3) << 28);
  *((uint32_t*)(0x400C4050 + 0x28 * channel)) = 0 | (0 << 4) | (1 << 9) | (1 << 13) | (1 << 16) | (0 << 20) | (0 << 21) | (0 << 22) | (0 << 24) | (1 << 28);
}

void DMA_SetupMultiTransfer(int channel, dma_transfer_descriptor_t* desc)
{
  REG_DMAC_EBCIDR |= 0x10101 << channel;//Disable Interupts
  *((uint32_t*)(0x400C403C + 0x28 * channel)) = 0;
  *((uint32_t*)(0x400C4040 + 0x28 * channel)) = 0;
  *((uint32_t*)(0x400C4044 + 0x28 * channel)) = (uint32_t)desc;
  *((uint32_t*)(0x400C4048 + 0x28 * channel)) = 0;
  *((uint32_t*)(0x400C404C + 0x28 * channel)) = 0;
  *((uint32_t*)(0x400C4050 + 0x28 * channel)) = 0 | (0 << 4) | (1 << 9) | (1 << 13) | (0 << 16) | (0 << 20) | (0 << 21) | (0 << 22) | (0 << 24) | (1 << 28);
}

void DMA_EnableChannel(int channel)
{
  REG_DMAC_CHER |= 1 << channel;
}

void DMA_DisableChannel(int channel)
{
  REG_DMAC_CHDR |= 1 << channel;
}

int DMA_IsChannelEnabled(int channel)
{
  return (REG_DMAC_CHSR >> channel) & 1;
}

dma.h:
Code:
#ifndef __DMA_H__
#define __DMA_H__
#include <Arduino.h>
#define DMA_WIDTH_BYTE  0
#define DMA_WIDTH_HALF_WORD  1
#define DMA_WIDTH_WORD  2

#define DMA_FC_MEM2MEM  0
#define DMA_FC_MEM2PER  1
#define DMA_FC_PER2MEM  2
#define DMA_FC_PER2PER  2

#define DMA_INCR_INCREMENTING  0
#define DMA_INCR_DECREMENTING  1
#define DMA_INCR_FIXED  2

typedef struct {
  uint32_t ul_source_addr;      /**< Source buffer address */
  uint32_t ul_destination_addr; /**< Destination buffer address */
  uint32_t ul_ctrlA;            /**< Control A register settings */
  uint32_t ul_ctrlB;            /**< Control B register settings */
  uint32_t ul_descriptor_addr;  /**< Next descriptor address */
}
dma_transfer_descriptor_t;

void DMA_Init();
void DMA_SetupTransfer(int channel, void* src, int src_length, int src_width, int src_incr, void* dst, int dst_width, int dst_incr, int flow_control);
void DMA_SetupMultiTransfer(int channel, dma_transfer_descriptor_t* desc);
void DMA_EnableChannel(int channel);
void DMA_DisableChannel(int channel);
int DMA_IsChannelEnabled(int channel);
#endif

This reads 512 samples from D0-D7, and sends them over the serial port (I have not tested, but I think it should work):
Code:
#include "dma.h"
byte result[512];
void setup()
{
    Serial.begin(9600);
    pinMode(25, INPUT);//D0
    pinMode(26, INPUT);//D1
    pinMode(27, INPUT);//D2
    pinMode(28, INPUT);//D3
    pinMode(14, INPUT);//D4
    pinMode(15, INPUT);//D5
    pinMode(29, INPUT);//D6
    pinMode(11, INPUT);//D7
    DMA_Init();
    DMA_SetupTransfer(1, (void*)&REG_PIOD_PDSR, 512, DMA_WIDTH_BYTE, DMA_INCR_FIXED, &result[0], DMA_WIDTH_BYTE, DMA_INCR_INCREMENTING, DMA_FC_MEM2MEM);
    DMA_EnableChannel(1);
    while(DMA_IsChannelEnabled(1));
    for(int i = 0; i < 512; i++)
   {
      Serial.println(result[i], HEX);
   }
}

...
I think it's a risk to use i.e. C for input and(!) output or you should be very careful to avoid reading from an output pin or writing to an input pin.
That's no problem. The pins are written using a different register than that is used for reading.
12  Products / Arduino Due / Re: Arduino Due digital read speed on: July 04, 2014, 12:24:13 am
Its quite involved setting up DMA, re-reading the datasheet a few times in the relevant
sections is a start.  However it should be able to do fancy stuff like this AFAICT.

Assembler is not needed, all IO is memory mapped so C is fine for all the low
level stuff on the ARM which is nice!  Its worth getting to look at the relevant
files in libsam for each piece of hardware to get a feel for things - you have all
the source code after all!
I made some code to make using DMA much simpler. I can post it here if you want.
13  Products / Arduino Due / Re: Arduino Due digital read speed on: July 03, 2014, 02:49:01 am
I see.  Do you know what the minimum time between digital reads would be then, without having to use assembly?  As in, could I read the same digital input pin at 3MHz?  15MHz is probably a pipe dream considering all the other processes the arduino must handle
As far as I know should the pio be able to read at 21MHz max. The problem is that you can try to read the inputs as fast as possible, but you can't control the speed. That's a big problem. DMA had been great if you could control it's speed.

You can use noInterrupts(); to disable interrupts. You need to use loop unrolling and assembly if you want to go that fast using the cpu. The DMA is (depending on the channel used) probably somewhere between 84 and 21 MHz or something. But I am nit sure.
14  Products / Arduino Due / Re: Arduino Due digital read speed on: July 02, 2014, 02:04:27 am
Hey guys,

I just bought an Arudino Due because I wanted the higher performance.  I was wondering though, is the Due capable of reading digital inputs at 15MHz?  I figure with a clock speed of 84MHz, it's gotta be able to read digital inputs at some respectable fraction of that.  I've tried looking for this information in the Arduino pages but didn't find anything that clearly answered this question

Thanks for reading

It should be possible. But I think you'll have to use a bit of assembly for it. And it is not possible to time it correctly. You can also use DMA, but that is probably too fast.
15  Products / Arduino Due / Re: main() vs. setup() + loop() on: June 06, 2014, 07:58:41 am
This is the main function:
Code:
int main( void )
{
init();

delay(1);

#if defined(USBCON)
USBDevice.attach();
#endif

setup();

for (;;)
{
loop();
if (serialEventRun) serialEventRun();
}

return 0;
}
Pages: [1] 2 3 ... 10