Go Down

Topic: call a function from another chip? (Read 965 times) previous topic - next topic


I want to use the 2313a for serial shiftIN, to multiplex buttons and keypads (to use less pins on the UNO), 'cause I don't have any multiplex IC's.

You could use my ICSC (Inter-Chip Serial Communication) library that I'm working on:


thanks, I'll look into it.


I've managed to establish serial communication between two 328P-PU's, however there is one problem:

I'm building a midi controller and I want to have the main code (incl. MIDI Library) on a 328P-PU and use an attiny2313a to multiplex/shiftIn an array of buttons to the 328P-PU.

I've tried different setups yesterday to see how I would deal with the 2kb flash memory limitation of the attiny2313a. I chose Attiny2313a as the target board to see if a sketch including the MIDI library would fit on it, it doesn't. Here's the sketch:

Code: [Select]
#include <MIDI.h>

PROGMEM byte buttonNumber[8] = {1,2,3,4,5,6,7,8};
boolean currentButtonState;

void setup() {

  for (byte a = 0; a<1; a++) {
    pinMode(buttonNumber[a], INPUT); 
    digitalWrite(buttonNumber[a], HIGH);


void loop() {
  for (byte i = 0; i<1; i++) {
      currentButtonState = digitalRead(buttonNumber[i]);
        if (currentButtonState == LOW) {
          MIDI.sendProgramChange(buttonNumber[i], 10);

Then I tried the sketch without the MIDI library, instead I used the Serial library to send messages to the 328P on the UNO, that did not work, or at least I don't know how to set up communication if the two chips have the serial ports running at different baud rates, i.e. MIDI library at 31250 and the Serial library at 9600.

I don't know what to do now, can you guys give me a hint?


MIDI is just Serial running at 31250 baud.  You can create MIDI streams manually without using the MIDI library.  Learning the MIDI protocol might help: https://ccrma.stanford.edu/~craig/articles/linuxmidi/misc/essenmidi.html

Then you can just use the attiny as a MIDI instrument manually sending the note on / note off commands over serial.

The 328P will have to run at 31250 baud and be a MIDI receiver accepting the note on / note off commands.
Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10


Then you can just use the attiny as a MIDI instrument manually sending the note on / note off commands over serial.

I forgot to mention that I don't really need the MIDI library on the attiny2313a, all I need is a way for buttons hooked up to the attiny to call functions located on the 328P. It does not matter to me what type of message the attiny sends to the 328P, be it midi or something else. I actually would prefer a way where the attiny would send a short string according to the button pushed and the 328 would read that string and call the appropriate function from the MIDI library.


btw, is it complicated to send messages over the serial port without using the Serial library?
I reckon that dedicated serial ShiftIn chips like the CD4021BE have a simplified mini version of the serial library?


You can send bytes via i2c.  There's a tut on the site on how to do that with attiny.

Go Up