Show Posts
Pages: [1] 2 3 ... 11
1  Products / Arduino Due / Re: CapacitiveSensorDue not working on: March 05, 2014, 10:59:56 am
I just used the example sketch, not more.
2  Products / Arduino Due / CapacitiveSensorDue not working on: March 05, 2014, 10:24:54 am
Hi everyone,
i'm trying to build a capacitive keyboard using  the CapacitiveSensor Library. I guess CapacitiveSensorDue does NOT work since i've tried a lot of pin combination with as much resister values, but it always returns me -1 (that meas it exceed the timeout).
Did anyone found the same issue and solve it?

Thanks a lot
3  Products / Arduino Due / Re: attachInterrupt on HIGH level on: January 18, 2014, 07:35:17 am
Since i'm using ethernet pins PB3 and PB4  should the function be like this?
Code:
void deglitch(Pio* pPio, uint32_t bitMask)
{
    pPio -> PIO_SCIFSR |= bitMask; // Glitch Input Filter Select Register
    pPio -> PIO_IFER |= bitMask;
}
4  Products / Arduino Due / Re: attachInterrupt on HIGH level on: January 17, 2014, 04:11:40 am
i need to use attachInterrupt HIGH. my sam3x is connected to a PIC10F204 which controls the board's switching off. when i press the power button for more than 2 seconds the PIC sends an HIGH signal to the SAM and i'm afraid RISING could be triggered from some kind of noise
5  Products / Arduino Due / attachInterrupt on HIGH level on: January 16, 2014, 11:07:21 am
Hi everyone,
i'm facing problems in implementing an interrupt triggered by HIGH level on a pin

Code:
int pin = 12;
volatile int state = LOW;

void setup()
{
  Serial.begin(9600);
 
  pinMode(pin, OUTPUT);
  digitalWrite(pin, LOW);
  Serial.println(state);
  pinMode(2, INPUT);
  Serial.println(state);
  attachInterrupt(2, blink, HIGH);
  Serial.println(state);
}

void loop()
{
 
  digitalWrite(pin, state);
}

void blink()
{
  delayMicroseconds(20000);
  state = !state;
}

the answer i have from the serial monitor is

0
0
1

Therefore i can only suppose that the attachInterrupt function changes in sort of of way the pin status. How come?
6  Products / Arduino Due / Re: Override attachInterrupt() on: January 13, 2014, 07:58:31 am
__initialize() function is explained in WInterrupts.h/.c
7  Products / Arduino Due / Re: serial.available() from polling to interrupt on: January 13, 2014, 07:57:09 am
No, i couldn't becouse i'm not currently working on an Arduino DUE but on a SAM3X based board, therefor i can't make hardware changes, but i'll try that solution asap
8  Products / Arduino Due / Re: Override attachInterrupt() on: January 10, 2014, 12:41:26 pm
replacing my version  _attachInterrupt() with the original attaInterrupt() does not change how the code works. it just stops as soon as i call the function in the setup.
has anyone ever meet this kind of problem?
9  Products / Arduino Due / Re: Override attachInterrupt() on: January 10, 2014, 12:04:45 pm
with a couple of printing i saw that it stops right when _attachInterrupt is called. It does not go further! How come?
10  Products / Arduino Due / Re: Override attachInterrupt() on: January 10, 2014, 09:35:38 am
OK, then i added a new function in WInterrupts.h/.c implemented like this:
Code:
void _attachInterrupt(Pio* pPio, uint32_t dwMask, void (*callback)(void), uint32_t mode)
{
static int enabled = 0;
if (!enabled)
{
__initialize();
enabled = 1;
}

uint32_t pos = 0;
uint32_t t;

for (t = dwMask; t > 1; t >>= 1, pos++);

// Set callback function
if (pPio == PIOA) callbacksPioA[pos] = callback;
if (pPio == PIOB) callbacksPioB[pos] = callback;
if (pPio == PIOC) callbacksPioC[pos] = callback;
if (pPio == PIOD) callbacksPioD[pos] = callback;

// Configure the Interrupt mode
if (mode == CHANGE)
{
// Disable additional interupt mode (detects both rising and falling edge)
pPio -> PIO_AIMDR = dwMask;
}
else
{
// Enable aditional interrupt mode
pPio -> PIO_AIMER = dwMask;

if (mode == LOW)
{
pPio -> PIO_LSR = dwMask;       // Level select register
pPio -> PIO_FELLSR = dwMask;     // Falling edge/ Low level Select Register
}
if (mode == HIGH)
{
pPio -> PIO_LSR = dwMask;     // Level select register
pPio -> PIO_REHLSR = dwMask;  // Rising Edge High Level Select Register
}
if (mode == FALLING)
{
pPio -> PIO_ESR = dwMask;     // Edge select register
pPio -> PIO_FELLSR = dwMask;  //Falling Edge Low Level Select Register
}
if (mode == RISING)
{
pPio -> PIO_ESR = dwMask;      //Edge Select Register
pPio -> PIO_REHLSR = dwMask;   //Rising Edge High Level Select Register
}
}

//Enable Interrupt
pPio -> PIO_IER = dwMask;

}

just the same as the orginal attachInterrupt(), the only difference stays in the fact that i can directly pass PIO port and BitMask to use a pin not declared in variant.h (I need to attach an Interrupt to PIOB3, one of the ethernet pins).

Of course this is not working, or at least it make the code to get stucked:
this is the working code:

Code:

volatile boolean off = false;

void setup()
{
  Serial3.begin(115200);
  delay(20);
  init_motor_pins();
 
  pmc_enable_sleepmode(0);
}

void loop()
{

  if (off)
  {
    off = false;
   //Set OUT_CPU pin LOW
    PIOB -> PIO_CODR = OUT_CPU_BM;
  }

  for (uint8_t k = 0; k < 28; k++)
  {
    value[k] = readCapacitivePin(k);
    //    Serial3.println(value[k]);
  }
  //Serial3.println();

  for (uint8_t k = 0; k < 28; k++)
  {
    if ((value[k] > edge[k] + range) & (pressed[k] == 0))
    {
      //Serial3.print("TOCCATO ");
      //Serial3.println(k);
      touched(k);
      pressed[k] = 1;
    }
    if ((value[k] <= edge[k]) & (pressed[k] == 1))
    {
      //Serial3.print("RILASCIATO ");
      //Serial3.println(k);
      pressed[k] = 0;
    }
  }

  pmc_enable_sleepmode(0);

  if (Serial3.available())
  { //change Serial3 to Serial31 if using BT
    char lettera = (char)Serial3.read();
Serial.print(lettera);
}

void _off()
{
delay(5);
off = true;
}

if add my _attachInterrupt() function in the setup everything stop working:

Code:
void setup()
{
  Serial3.begin(115200);
  delay(20);
  init_motor_pins();
 
/////////////////////////////////////
_attachInterrupt(PIOB, IN_CPU_BM, _off, LOW);
////////////////////////////////////

  pmc_enable_sleepmode(0);
}

do you have any idea of what could be happening and why the code it's not working anymore?
11  Products / Arduino Due / Override attachInterrupt() on: January 07, 2014, 06:32:59 am
Hi everyone,
I'm working on an Arduino Due custom board and i need to use interrupts on other pins not numbered on the orginal board.
Thus i rewrited the attachInterrupt function in this way:
Code:
void attachInterrupt(Pio* pPio, uint32_t dwMask, void (*callback)(void), uint32_t mode)
{
static int enabled = 0;
if (!enabled)
{
__initialize();
enabled = 1;
}

uint32_t pos = 0;
uint32_t t;

for (t = dwMask; t > 1; t >>= 1; pos++);

// Set callback function
if (pPio == PIOA) callbacksPioA[pos] = callback;
if (pPio == PIOB) callbacksPioB[pos] = callback;
if (pPio == PIOC) callbacksPioC[pos] = callback;
if (pPio == PIOD) callbacksPioD[pos] = callback;

// Configure the Interrupt mode
if (mode == CHANGE)
{
// Disable additional interupt mode (detects both rising and falling edge)
pPio -> PIO_AIMDR = dwMask;
}
else
{
// Enable aditional interrupt mode
pPio -> PIO_AIMER = dwMask;

if (mode == LOW)
{
pPio -> PIO_LSR = dwMask;       // Level select register
pPio -> PIOFELLSR = dwMask;     // Falling edge/ Low level Select Register
}
if (mode == HIGH)
{
pPio -> PIO_LSR = dwMask;     // Level select register
pPio -> PIO_REHLSR = dwMask;  // Rising Edge High Level Select Register
}
if (mode == FALLING)
{
pPio -> PIO_ESR = dwMask;     // Edge select register
pPio -> PIO_FELLSR = dwMask;  //Falling Edge Low Level Select Register
}
if (mode == RISING)
{
pPio -> PIO_ESR = dwMask;      //Edge Select Register
pPio -> PIO_REHLSR = dwMask;   //Rising Edge High Level Select Register
}
}

//Enable Interrupt
pPio -> PIO_IER = dwMask;

}

My first try has been to override the function, but when compiling it tells me that the two functions do conflict.  is there anything wrong in the code i wrote?

 i did anything but allowing attachInterrupt to be used declaring Port e bitmask to select the rught pin
12  Products / Arduino Due / Re: wake up from sleep mode through serial interrupt on: January 07, 2014, 06:09:13 am
thanks Kove,
this stackoveflow post seems to confirm my method. It suggests even to try the backupMode, but the datasheet recommend to use backMode only for long wakepu time (wake up from back up mode takes approximately 0.5 ms that is too long for my application.) .
13  Products / Arduino Due / Re: wake up from sleep mode through serial interrupt on: January 02, 2014, 09:36:46 am
Code:
void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pmc_enable_sleepmode(0);
}

void loop() {
  // put your main code here, to run repeatedly:
if(Serial.available())
{
  Serial.print(Serial.read());
  pmc_enable_sleepmode(0);
  }
}

this code seems to work, at least it echoes what i write on the serial. The problem is that i can't check the currrent consuption since i don't have a laboratory power supply
14  Products / Arduino Due / wake up from sleep mode through serial interrupt on: December 30, 2013, 06:59:24 am
Hi every one,
I'd like to put the SAM3X in sleep mode till something is receveid on the serial port. At section 5.5.3 of the SAM3X datasheet is written

 
Quote
The purpose of sleep mode is to optimize power consumption of the device versus response
time. In this mode, only the core clock is stopped. The peripheral clocks can be enabled. This
mode is entered via Wait for Interrupt (WFI) or Wait for Event (WFE) instructions with LPM = 0 in
PMC_FSMR.26
11057B–ATARM–28-May-12
SAM3X/A
The processor can be awakened from an interrupt if WFI instruction of the Cortex M3 is used, or
from an event if the WFE instruction is used to enter this mode.

do you think that the wakeup from the sleep mode should happen automatically if the interrupt procedure of the serial port is called?

15  Products / Arduino Due / Re: serial.available() from polling to interrupt on: December 30, 2013, 06:04:00 am
none of the above solutions has worked till now. thus i was thinking of editing USART/UARTClass cpp file, including a flag in the interrupt code of the usart that will help me wake up chip. what do you think about?
Pages: [1] 2 3 ... 11