Pages: [1]   Go Down
Author Topic: serial programming with interrupt on arduino due board  (Read 1268 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,
      I am programming serial communication on Arduino due board with Cortex M0 controller,but with interrrupt programming.But it is not working?
It is possible or not?

Please give me reply as early as possible
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 638
Posts: 50304
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I am programming serial communication on Arduino due board with Cortex M0 controller
That programming looks like?

Quote
but with interrrupt programming.
Why? Why isn't polling adequate? What is sending the serial data? How much? How often?

Quote
But it is not working?
It isn't? Are you sure? Don't you know?

Quote
It is possible or not?
Yes.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello sir,
      I have checked serial communication with interrupt,but it not working. Please help me programming wise.
I have used attachInterrupt(2, buttonPress, CHANGE) function for external interrupt0. Here 'buttonPress' it is function
whichcan be called at interrupt.
      Depending upon pressing a button, i have send one string on serial monitor through ISR routine.But it is not printing.
What i do?
Give me suggestion.
Logged

New England
Offline Offline
Sr. Member
****
Karma: 7
Posts: 295
Natural Semiinductor
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The sketch you are using is too far away to see, it. Can you place the source code software on my video screen? I will poll my screen in one hour without using an interrupt tonight.
Logged

I am going to get going.

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am using panic button,depending upon their condition serial monitor get printed.below my code-



volatile int ButtonPin=2;               //one panic button attached to pin no 2 for generation of interrupt
int LEDpin=13;
int buttonState=HIGH;                 //first state of button
volatile boolean serial_flag=false;   //flag used in serial communication

void setup() {
  // put your setup code here, to run once:
 
  pinMode(ButtonPin,INPUT);
  pinMode(LEDpin,OUTPUT);
 
 
 
  //enable Interrupt0 which is connect to button
  attachInterrupt(2, buttonPress, CHANGE);
 
  //turn ON serial communication
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:

    if(serial_flag)
    {
       Serial.print("not pressed\n");
       serial_flag=false;
    }

    else
    {
       Serial.print("not pressed\n");
    }
 
}



void buttonPress()      //this is my ISR
{
     serial_flag=true;
}
Logged

0
Offline Offline
God Member
*****
Karma: 26
Posts: 621
Always making something...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Your code prints the same "not pressed\n" message in either case.  How can you tell if it is working if the 2 cases print exactly the same thing?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

sorry its my mistake,but i have change that one
   since it is giving me "not pressed" on serial port,and when i press button then it get stop.



volatile int ButtonPin=2;               //one panic button attached to pin no 2 for generation of interrupt
int LEDpin=13;
int buttonState=HIGH;                 //first state of button
volatile boolean serial_flag=false;   //flag used in serial communication

void setup() {
  // put your setup code here, to run once:
 
  pinMode(ButtonPin,INPUT);
  pinMode(LEDpin,OUTPUT);
 
 
 
  //enable Interrupt0 which is connect to button
  attachInterrupt(2, buttonPress, CHANGE);
 
  //turn ON serial communication
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:

    if(serial_flag)
    {
       Serial.print("pressed\n");
       serial_flag=false;
    }

    else
    {
       Serial.print("not pressed\n");
    }
 
}



void buttonPress()      //this is my ISR
{
     serial_flag=true;
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

please anybody help me out for this as early as possible
Logged

Sydney, NSW
Offline Offline
Jr. Member
**
Karma: 1
Posts: 83
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I had similar problems using the interrupt once before, what does the hardware setup of the button look like?
Also don't forget to factor in debouncing if its a button.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

have you check my above code?about hardware setup
one end of button is connected to ground & other end is connected to VCC by pull up resistor.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can anybody tell me for this my problem
Logged

Sydney, NSW
Offline Offline
Jr. Member
**
Karma: 1
Posts: 83
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

have you check my above code?about hardware setup
one end of button is connected to ground & other end is connected to VCC by pull up resistor.

This might seem like a silly question but I'm guessing you also have one end of the button connected to pin 2 right?
The code is looking okay, unless I'm missing something?
I'm not sure if it helps but would it be easier if the interrupt was set to a RISING or FALLING edge? That way you it wouldn't have as much of a problem with debouncing. But I'm guessing that still won't fix your problem.
« Last Edit: September 07, 2013, 11:26:35 am by trustnoone » Logged

Pages: [1]   Go Up
Jump to: