Jump to content


Photo

Multitasking the "arduino" functionality


3 replies to this topic

#1 smily03

smily03

    Advanced Member

  • Members
  • PipPipPip
  • 55 posts

Posted 21 October 2016 - 03:15 AM

I noticed something odd this evening. It doesn't look like the "arduino" functionality of the PCD8 can multitask?

 

Basically - I added a "heartbeat" binary to my PCD so that I can, at a glance, see whether it's responding. This is the same basic functionality as is on my beaglebone and odroid. The binary is set to load on each reboot automatically via a cron job:

#include <core.h>
int led_pin = 13;

void setup() {
 pinMode(led_pin, OUTPUT);
}

void loop() {
  digitalWrite(led_pin, HIGH);  // set the LED on
  delay(100);                                  // wait for a second
  digitalWrite(led_pin, LOW);       // set the LED off
  delay(400);                                  // wait for a second
  digitalWrite(led_pin, HIGH);  // set the LED on
  delay(100);                                  // wait for a second
  digitalWrite(led_pin, LOW);       // set the LED off
  delay(1000);                                  // wait for a second
}

The heartbeat blinker works fine. However, when I try to do something else, like blink an LED attached to each of the digital pins, one after the other, the output is interrupted by each "blink" of the blink binary...?

#include <core.h>

void setup() {
  for (int p=0; p < 13; p++) {
    pinMode(p, OUTPUT);
  }
}

void loop() {
  for (int pin=0; pin < 13; pin++) {
    digitalWrite(pin, HIGH);  // set the LED on
    delay(1000);                                  // wait for a second
    digitalWrite(pin, LOW);       // set the LED off
    delay(1000);
  }
}

Eg. -- each time the onboard LED blinks, the other LEDs turn off: https://drive.google...Wi0yWHlza2QyelE

 

However, if the blink binary isn't running at the time, it works properly: https://drive.google...Q1k2MGpURFpYaDA

 

That seems odd and sort of annoying...

 

 



#2 smily03

smily03

    Advanced Member

  • Members
  • PipPipPip
  • 55 posts

Posted 21 October 2016 - 03:39 AM

I should also note that no, disabling my "blink" code doesn't fix the problems I'm having with accessing the uarts, debug console, video, etc.



#3 youkee

youkee

    Advanced Member

  • Administrators
  • 237 posts

Posted 24 October 2016 - 12:50 PM

for (int pin=0; pin < 13; pin++) {
digitalWrite(pin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(pin, LOW); // set the LED off
delay(1000);
}

for this logic, every 13x2 s, each GPIO will blink one time, that's you want to implement, right?



#4 smily03

smily03

    Advanced Member

  • Members
  • PipPipPip
  • 55 posts

Posted 29 October 2016 - 03:39 AM

Not really. Basically what the code does is iterate through each digital pin one after the other. For each pin, it turns on, waits a second, then turns off, then waits a second.

But when a second process is writing to other pins, you can see from the videos that it interrupts the other processes (hence the sporadic blinking.)



Reply to this topic



  


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users