1
\$\begingroup\$

I am still fairly new to programming, so I'm sorry in advance if my terminology/formatting isn't up to scratch.

I am currently working on an element of a musical instrument that will allow me to actuate a button multiple times with a varying time delay between presses, record this and loop the pattern.

I currently have an array for recording the timings of the button presses, I am using USB-UART/terra term to check my values are being recorded correctly but I am finding the array being populated with seemingly nonsensical values. I am wondering where this data is coming from.

Highlighted in red in the image below are the values that I expect to be retained in the T0, T1..etc values. In short - Mtapi is the int used in selecting what location in the array I want to store the current milliTAP value (T0, T1 etc..). But as you can see from the following data lines they are being replaced by 10 digit numbers.

Basically, I am wondering what those numbers are, why I am seeing them and how to stop them populating my array!

I did think they maybe something to do with data locations of the array instances? but honestly this is all new to me and I have no idea. That and how they are changing at what seems to be random to me.

teraterm

Any help or direction to further reading is much appreciated.

you can see the code on GigHub here

for quick reference (shortened for posting here):-

if ((Mtapi==0)&&(MTap[0]>0)&&(MTapBtnCHK==0))
{
     int i;
     for (int i=0; i<63; i++)
     {
         MTap[i]=0;    
     }
}

if (MTapBtn_Read()==0)
{
    MultiTapTempo();
}
if (MTapBtn_Read()==1)
{
    MTapBtnCHK=0;
}

//gap in code posted here, then:

void MultiTapTempo(void)
{
    if (MTapBtnCHK==0)
    {
        Mtapi++;
        MTapBtnCHK=1;

        if(Mtapi==0){}
        if(Mtapi==1){MTap[0]=millisMTAP;}
        if(Mtapi==2){MTap[1]=millisMTAP;}
        if(Mtapi==3){MTap[2]=millisMTAP;}
        if(Mtapi==4){MTap[3]=millisMTAP;}
        if(Mtapi==5){MTap[4]=millisMTAP;}
        if(Mtapi==6){MTap[5]=millisMTAP;}
        if(Mtapi==7){MTap[6]=millisMTAP;}
        if(Mtapi==8){MTap[7]=millisMTAP;}
        if(Mtapi==9){MTap[8]=millisMTAP;}
     }
\$\endgroup\$
3
  • \$\begingroup\$ Looks like you standard bouncing of push buttons. Look up "de-bouncing buttons" \$\endgroup\$
    – Oldfart
    Commented Oct 8, 2018 at 18:32
  • \$\begingroup\$ debouncing is covered elsewhere in the code. the problem was to do with the character array sending the data over UART not being big enough. \$\endgroup\$ Commented Oct 8, 2018 at 19:01
  • \$\begingroup\$ also some basic code comments might help determine what you are trying to accomplish (in case it isn't doing what you think it's doing). Also where is millisMTAP coming from, as it isn't declared in your function MultiTapTempo \$\endgroup\$ Commented Oct 8, 2018 at 19:52

1 Answer 1

1
\$\begingroup\$

the problem was that my character array holding the data to send over UART was not large enough to hold the information i was trying to send.

this line in the code--

char buff[64];//output UART buffer
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.