Show Posts
Pages: 1 2 3 [4] 5 6 ... 10
46  Products / Arduino Due / Re: A/D sampling frequency on: November 30, 2013, 05:19:06 am
How can I reach 100Ksps if the AnalogRead() takes 39us? ...
Use native code. Take a look over here:
47  Products / Arduino Due / Re: A/D sampling frequency on: November 28, 2013, 03:58:01 pm
Ok, then the maximum sampling rate is 1 MHz?
Yes, but only under perfect conditions.
48  Products / Arduino Due / Re: Arduino Due blink example in assembly on: November 28, 2013, 03:33:44 pm
I've found this example but as i found out it's for arduino uno I've managed to find the addresses for the Due but it still doesn't work. Any help would be much appreciated .

void setup() {
  asm volatile (
    "sbi %0, %1 \n\t"           //pinMode(13, OUTPUT);
    :: "I" (_SFR_IO_ADDR(DDRB)), "I" (DDB5)
void loop() {
  asm volatile (
     "sbi %0, %1 \n\t"          //LED on
     "call OneSecondDelay \n\t" //delay
     "cbi %0, %1 \n\t"          //LED off
     "call OneSecondDelay \n\t" //delay
     "rjmp 4f \n\t"             //exit
  "OneSecondDelay: \n\t"
     "ldi r18, 0 \n\t"          //delay 1 second
     "ldi r20, 0 \n\t"
     "ldi r21, 0 \n\t"
  "1: ldi r24, lo8(400) \n\t"
     "ldi r25, hi8(400) \n\t"
  "2: sbiw r24, 1 \n\t"         //10x around this loop = 1ms
     "brne 2b \n\t"
     "inc r18 \n\t"
     "cpi r18, 10 \n\t"
     "brne 1b \n\t"
     "subi r20, 0xff \n\t"      //1000 x 1ms = 1 second
     "sbci r21, 0xff \n\t"
     "ldi r24, hi8(1000) \n\t"
     "cpi r20, lo8(1000) \n\t"
     "cpc r21, r24 \n\t"
     "breq 3f \n\t"
     "ldi r18, 0 \n\t"
     "rjmp 1b \n\t"
  "3: \n\t"
     "ret \n\t"
  "4: \n\t"                     //exit
     :: "I" (_SFR_IO_ADDR(PORTB)), "I" (PORTB5)
     : "r18", "r20", "r21", "r24", "r25"
This is avr assembly. You need arm assembly. As for the registers, yes, it's irritating that it lacks a lot of documentation.
49  Products / Arduino Due / Re: Arduino Due blink example in assembly on: November 28, 2013, 02:07:40 am
I've searched the web but there isn't much on the subject.
I'm not surprised, no-one in their right mind would use assembly these days unless there is a VERY good reason.

To start from scratch with no C would be a nightmare, but to use inline ASM in your C sketch would be ok so search for examples of inline assembly, get the SAM instruction set docs and start experimenting using some other code as a base.

Good luck, is there a particular reason you want to know the ARM at this level? Very few people need that knowledge.

ARM is not very complex. But it would be much easier if you could use real .s files instead of inline assembly.
50  Products / Arduino Due / Re: Arduino Due blink example in assembly on: November 27, 2013, 03:18:46 pm
Good evening everyone I'm trying to understand the arm processor by using the Arduino Due and it could be a real help if someone could give me the blink example in assembly for the Arduino Due.I've searched the web but there isn't much on the subject.Thank you.
Sadly the arduino ide doesn't support .s files. But you can use inline assembly.
51  Products / Arduino Due / Re: How to get Vendor ID and Product Id of connected USB Device On Arduino Due board on: November 26, 2013, 02:33:02 am
Gericom: Please excuse my delay in responding to your suggestion on vendor/product id.  What you say is surely possible and I have seen an unofficial list of USB vendor/product ids somewhere in web forum.  But the basic problem is you cannot be too sure of what you get ... you know many users use multiple accounts to post in forums... smiley-wink

I think vijayPatil14 needs to distinguish what he wants to read:  the vendor/product ids of a media card is simply not easy to get if being used with a card reader.  Getting the USB Dev Descriptor's Vendor/product id would get him the id of card reader... not what is mounted on it.   Does this mean it is impossible to know the SD Assoc defined CID, CSD using a card reader?  Hardly.
If I am the manufacturer, I might leave a mechanism (vendor unique SCSI Command) to get that when working with common  media cards like SD, SDIO, CompactFlash, MMC2, stick(?), etc.
If he wants to know how to process the USB descriptors, I recently made available the mass storage class driver for Native USB port and it has all the code needed to extract the four primary descriptors: dev, config, interface & endpoint.  Look into doMscConfig().  While the driver code stops after discovering the first drivable interface, his code could carry on and discover all the descriptors if he likes.

The code I posted is part of my msd library for the due as well. It only works with 2 usb sticks so far. But this snipped works great.
52  Products / Arduino Due / Re: How to get Vendor ID and Product Id of connected USB Device On Arduino Due board on: November 08, 2013, 04:07:25 am
You can do something like this:
#include <Usb.h>

USBHost usb;

boolean found = false;

void setup()

void DeviceTest(UsbDevice *pdev)
     if(usb.getDevDescr(pdev->address, 0, DEV_DESCR_LEN, (byte*)&d) == 0)
            //Now use d.idVendor and d.idProduct to indentify your device.
            //If you have found the right one, store pdev global and set found to true.
53  Products / Arduino Due / Re: Reading analogical input and output it as analogical on: November 07, 2013, 02:27:58 am
I tried to send the sketch but I failed so I wrote the sketch I made:

float r1,r2;
void setup( )
void loop ( )
r1 = analogiRead(0);
r2= 2.5*r1;
analogWrite (DAC0,r2);
Why do you use a delay?
54  Products / Arduino Due / Re: How to get Vendor ID and Product Id of connected USB Device On Arduino Due board on: November 07, 2013, 02:26:17 am
Can you please share the code..
I will share it when I have time.
55  Products / Arduino Due / Re: How to get Vendor ID and Product Id of connected USB Device On Arduino Due board on: November 06, 2013, 01:49:24 pm
I will have to look it up. But I did it before.
56  Products / Arduino Due / Re: Waveform generation_DAC_faster speed on: November 06, 2013, 01:10:31 am
You can use a combination of a timer interrupt and some low level code. You can write to the 2 dacs at the same time using the word transfer mode in combination with the tag mode.
57  Products / Arduino Due / Re: How to get Vendor ID and Product Id of connected USB Device On Arduino Due board on: October 31, 2013, 01:57:13 am
It is not very difficult to read out them.

Each manufactor got it's own vendor id. And for each product, there is a product id. So if you have 2 of the same device, both id's are the same.
58  Products / Arduino Due / Re: sampling rate in arduino due on: October 28, 2013, 02:45:58 am
hello all,

i want to know what is the sampling rate of ADC in Due, and can it be altered to a certain frequency like 48khz (it is for audio input)


I think it was 1MHz.

For 48kHz you can just use an timer interrupt at 48kHz.
59  Products / Arduino Due / Re: What is the limit for array size on Arduino DUE? on: October 08, 2013, 02:00:19 pm
I think the cleanest way to declare an array is using a #define directive:
#define ARRAY_SIZE 65536   // maximum for Due
uint8_t array[ ARRAY_SIZE ];

IIRC I have used even bigger arrays. Like 93000 or something.
60  Products / Arduino Due / Re: Can anyone recommend low level USB host mass storage code for Due? on: October 06, 2013, 02:28:54 am

I am writing a new FAT12/FAT16/FAT32 library that cleanly separates the FAT filesystem code from the block device driver.  I am now testing with SD cards on SPI but the library supports any block device derived from this class.

class FatBlockDevice {
  // Return a code for an I/O error.
  virtual uint8_t hwErrorCode() const = 0;
  // Return extra data describing an I/O error.
  virtual uint8_t hwErrorData() const = 0;
  // Read a block from the device.
  virtual bool readBlock(uint32_t lbn, uint8_t* dst) = 0;

  // Write a block to the device.
  virtual bool writeBlock(uint32_t lbn, const uint8_t* src) = 0;

  // Optional multiple block transfers.
  virtual bool readBlocks(uint32_t lbn, uint16_t count, uint8_t* dst) = 0;

  virtual bool writeBlocks(uint32_t lbn, uint16_t count, const uint8_t* src) = 0;

For SD on SPI I use the class SdSpiCard that is defined like this:
class SdSpiCard : public FatBlockDevice {

This is how the equivalent of SdFat is setup:

#include <FatLib.h>
#include <SdSpiCard.h>

SdSpiCard card;

// The argument of FatFilesystem has type FatBlockDevice * .
FatFilesystem sd(&card);

FatPrintFile file;
void setup() {

  if (!card.begin() || !sd.begin()) {
    Serial.println("begin failed");



I am looking for a class for a USB flash drive to replace SdSpiCard.  For example a class UsbFlashDrive that is derived from FatBlockDevice like this:
class UsbFlashDrive : public FatBlockDevice {

Would this be possible with your setup/code?

I still need to do some development and cleanup and then I could send you my FatLib library.
That's very nice! That way I could implement my mass storage lib.
Pages: 1 2 3 [4] 5 6 ... 10