if I have a array I am looking to stuff can I use

if I have a array I am looking to stuff can I use a inline function to keep it fast and not return to it because the array is global?

So I have a global array of 24 bytes.

the function call inserts a constant int.

getbyte(int bytenum)
{
stuffarrray[bytenum];
}

used as:
getbyte(1);

can I use a inline function to keep it fast and not return to it because the array is global?

What is the "it" t which "it" should not return?

I have a global array.

it needs to be stuffed from pin input.

rather than incrementing that array in the main code I think calling a function would be better.
so since it is a global array I can input constants to define the array element and it changes the array values without returning anything.

here is a snapshot of the code

#include "pins.h" //the pin definitions pin number= name
#include "var.h" //global vareable definition

void setup()
{
//initilise the serial usb hardware check to see if a program has the port latter
Serial.begin(9600); // USB is always 12 Mbit/sec

init_pins_direction();

//if serial port has to be started the wait for dtr command might
//have to be commented out and run once.
while (!Serial.dtr()) ; // wait for user to start the serial monitor

Serial.println("This is the teensy++ TI ADS1278 ADC test program.");
int number = 1234;
Serial.println(number); // number (base 10 if 16 or 32 bit)
Serial.println(number, DEC); // number, base 10 (default)
Serial.println(number, HEX); // number, base 16/hexidecimal
Serial.println(number, BIN); // number, base 2/binary
Serial.println(number, BYTE); // number, as a single byte
Serial.send_now(); //transmit buffer imediately
}

void loop()
{

// read the state of the pushbutton value:
DRDY_State = digitalRead(DRDY);

if(DRDY_State==LOW){

clkoutallbytes();

print24arraybytes();
}//end of if DRDY is LOW ... this I hope is fast enough...

//PortB 7 is unconnected!

//two's compliment is the sign number

}//end of main

inline void print24arraybytes(void)
{
//now that the array is filled send the bytes up the usb if working with 64 byte buffer 3 samples 3bytes per channel*8channels=
//24byts per sample *2 = 48 bytes...
Serial.print(data_Out[0],BYTE);
Serial.print(data_Out[1],BYTE);
Serial.print(data_Out[2],BYTE);
Serial.print(data_Out[3],BYTE);
Serial.print(data_Out[4],BYTE);
Serial.print(data_Out[5],BYTE);
Serial.print(data_Out[6],BYTE);
Serial.print(data_Out[7],BYTE);
Serial.print(data_Out[8],BYTE);
Serial.print(data_Out[9],BYTE);
Serial.print(data_Out[10],BYTE);
Serial.print(data_Out[11],BYTE);
Serial.print(data_Out[12],BYTE);
Serial.print(data_Out[13],BYTE);
Serial.print(data_Out[14],BYTE);
Serial.print(data_Out[15],BYTE);
Serial.print(data_Out[16],BYTE);
Serial.print(data_Out[17],BYTE);
Serial.print(data_Out[18],BYTE);
Serial.print(data_Out[19],BYTE);
Serial.print(data_Out[20],BYTE);
Serial.print(data_Out[21],BYTE);
Serial.print(data_Out[22],BYTE);
Serial.print(data_Out[23],BYTE);

Serial.send_now(); //transmit buffer imediately
}

inline void init_pins_direction(void){
//initilise pins to a defalt state high or low
digitalWrite(ledPin, HIGH); // set the LED OFF it is active low
digitalWrite(SYNC, HIGH); //SYNC is active low init as HIGH
digitalWrite(SCLK, LOW); //SCLK rests low shifts out on falling edge

//initilise the direction of pins or ports
pinMode(ledPin, OUTPUT); // initialize the pin as an output:
pinMode(buttonPin, INPUT); // initialize the pushbutton pin as an input

pinMode(SCLK, OUTPUT); //SCLK comes out the micro into the ADC to clock out data
pinMode(DRDY, INPUT); //DRDY goes into the micro out of the ADC to say when a conversion is done
pinMode(SYNC, OUTPUT); //this is used to syncronise many ADCs

DDRB = 0; //set port b to input //test this using other led outputs...

}

inline void getMSB(void){
asm("nop\n\t"); //delay 1 cycle inline assembly. This is the delay tds "falling edge of #DRDY to rising edge of SCLK to retreve data"
digitalWrite(SCLK, HIGH); // set the SCLK HIGH tMSBPDDRDY FALLING EDGE TO MSB valid weight is taken.
//IF NOT BYTE OP. DO THIS 8 TIMES ... DRDY_State = digitalRead(DRDY);
data_Out[0]=PINB;//DO1 = LSB - DO8 = MSB... check wiring...
}

inline void getbyte(int bytenum){
digitalWrite(SCLK, LOW); // set the SCLK LOW GET NEXT BYTE
asm("nop\n\t"); //delay 1 cycle inline assembly. SCLK falling edge wait for valid data..
data_Out[bytenum]=PINB;
digitalWrite(SCLK, HIGH); // set the SCLK HIGH
asm("nop\n\t"); //delay to ensure valid pulse width

}

inline void clkoutallbytes(void){

//62.5ns per sclk check timing diagrams for ads1278
//1/12MHZ per clk 83ns

//get byte 1
getMSB();

//get byte 2
getbyte(1);

//get byte 3
getbyte(2);

//get byte 4
getbyte(3);

//get byte 5
getbyte(4);

//get byte 6
getbyte(5);

//get byte 7
getbyte(6);

//get byte 8
getbyte(7);

//get byte 9

You're up to over 80 posts - do you think you could use the "#" button, please?

it needs to be stuffed from pin input.

rather than incrementing that array

"stuffed"?

How do you "increment" an array?
Do you mean "extend"?

The array starts with all 0's I want it to take the input from the sensor and put it in the array. The array has a number going to it that specifies the array element. That in my main function the fuction has a input that is the index value for the array arrayelement[N];

button? I put the headers in .h files to make the first parts smaller and hyde them.

I think you're talking about indices (plural of "index").

Could you go back to the earlier post, click on "modify", then highlight all the code, then click on the "#" button in the editor, please?

What would that give me except for only # as my code.

In the top row of the buttons above the area where you type your messages, there is a button with a # sign on it. When you select the code, and push that button, tags are added before and after the highlighted text. The tags tell the forum software to display that text differently.

Try it, and see what happens.

course when you use the function in the IDE the above is exactly what it spits out

::slight_smile:

Oh I feel like a Noob I selected my code in the arduino enviroment and did that and replaced it all with a # ... I thought it was his way of saying take a walk. :smiley:

So ok here I will do that now thanks for clarifying.

oh much nicer.

#include "pins.h" //the pin definitions pin number= name
#include "var.h" //global vareable definition

void setup()
{
  //initilise the serial usb hardware check to see if a program has the port latter
  Serial.begin(9600); // USB is always 12 Mbit/sec

  init_pins_direction();

  //if serial port has to be started the wait for dtr command might
  //have to be commented out and run once.
  while (!Serial.dtr()) ;  // wait for user to start the serial monitor

    Serial.println("This is the teensy++ TI ADS1278 ADC test program.");
  int number = 1234;
  Serial.println(number);       // number (base 10 if 16 or 32 bit)
  Serial.println(number, DEC);  // number, base 10 (default)
  Serial.println(number, HEX);  // number, base 16/hexidecimal
  Serial.println(number, BIN);  // number, base 2/binary
  Serial.println(number, BYTE); // number, as a single byte
  Serial.send_now();            //transmit buffer imediately
}



void loop()
{

  // read the state of the pushbutton value:
  DRDY_State = digitalRead(DRDY);

  if(DRDY_State==LOW){

    clkoutallbytes();    

    print24arraybytes();
  }//end of if DRDY is LOW ... this I hope is fast enough...

  //PortB 7 is unconnected!

  //two's compliment is the sign number

}//end of main

inline void print24arraybytes(void)
{
  //now that the array is filled send the bytes up the usb if working with 64 byte buffer 3 samples 3bytes per channel*8channels= 
  //24byts per sample *2 = 48 bytes...
  Serial.print(data_Out[0],BYTE);
  Serial.print(data_Out[1],BYTE);
  Serial.print(data_Out[2],BYTE);
  Serial.print(data_Out[3],BYTE);
  Serial.print(data_Out[4],BYTE);
  Serial.print(data_Out[5],BYTE);
  Serial.print(data_Out[6],BYTE);
  Serial.print(data_Out[7],BYTE);
  Serial.print(data_Out[8],BYTE);
  Serial.print(data_Out[9],BYTE);
  Serial.print(data_Out[10],BYTE);
  Serial.print(data_Out[11],BYTE);
  Serial.print(data_Out[12],BYTE);
  Serial.print(data_Out[13],BYTE);
  Serial.print(data_Out[14],BYTE);
  Serial.print(data_Out[15],BYTE);
  Serial.print(data_Out[16],BYTE);
  Serial.print(data_Out[17],BYTE);
  Serial.print(data_Out[18],BYTE);
  Serial.print(data_Out[19],BYTE);
  Serial.print(data_Out[20],BYTE);
  Serial.print(data_Out[21],BYTE);
  Serial.print(data_Out[22],BYTE);
  Serial.print(data_Out[23],BYTE);

  Serial.send_now();            //transmit buffer imediately  
}

inline void init_pins_direction(void){
  //initilise pins to a defalt state high or low
  digitalWrite(ledPin, HIGH);   // set the LED OFF it is active low
  digitalWrite(SYNC, HIGH);   //SYNC is active low init as HIGH
  digitalWrite(SCLK, LOW);   //SCLK rests low shifts out on falling edge

  //initilise the direction of pins or ports
  pinMode(ledPin, OUTPUT);   // initialize the pin as an output:
  pinMode(buttonPin, INPUT);       // initialize the pushbutton pin as an input

  pinMode(SCLK, OUTPUT); //SCLK comes out the micro into the ADC to clock out data
  pinMode(DRDY, INPUT);  //DRDY goes into the micro out of the ADC to say when a conversion is done
  pinMode(SYNC, OUTPUT);  //this is used to syncronise many ADCs

  DDRB = 0; //set port b to input //test this using other led outputs...

}

inline void getMSB(void){
  __asm__("nop\n\t"); //delay 1 cycle inline assembly. This is the delay tds "falling edge of #DRDY to rising edge of SCLK  to retreve data"
  digitalWrite(SCLK, HIGH);   // set the SCLK HIGH tMSBPDDRDY FALLING EDGE TO MSB valid weight is taken.
  //IF NOT BYTE OP. DO THIS 8 TIMES ... DRDY_State = digitalRead(DRDY);
  data_Out[0]=PINB;//DO1 = LSB - DO8 = MSB... check wiring...  
}

inline void getbyte(int bytenum){
  digitalWrite(SCLK, LOW);   // set the SCLK LOW GET NEXT BYTE
  __asm__("nop\n\t"); //delay 1 cycle inline assembly. SCLK falling edge wait for valid data..
  data_Out[bytenum]=PINB;
  digitalWrite(SCLK, HIGH);   // set the SCLK HIGH 
  __asm__("nop\n\t"); //delay to ensure valid pulse width

}

inline void clkoutallbytes(void){

  //62.5ns per sclk check timing diagrams for ads1278
  //1/12MHZ per clk 83ns

  //get byte 1
  getMSB();    

  //get byte 2
  getbyte(1);    

  //get byte 3
  getbyte(2);    

  //get byte 4
  getbyte(3);    

  //get byte 5
  getbyte(4);    

  //get byte 6
  getbyte(5);    

  //get byte 7
  getbyte(6);    

  //get byte 8
  getbyte(7);    

  //get byte 9
  getbyte(8);    

  //get byte 10
  getbyte(9);    

  //get byte 11
  getbyte(10);    

  //get byte 12
  getbyte(11);    

  //get byte 13
  getbyte(12);    

  //get byte 14
  getbyte(13);    

  //get byte 15
  getbyte(14);    

  //get byte 16
  getbyte(15);    

  //get byte 17
  getbyte(16);    

  //get byte 18
  getbyte(17);    

  //get byte 19
  getbyte(18);    

  //get byte 20
  getbyte(19);    

  //get byte 21
  getbyte(20);    

  //get byte 22
  getbyte(21);    

  //get byte 23
  getbyte(22);    

  //get byte 24
  getbyte(23);    

}