1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

strange array values (C, psoc, usbuart)

Discussion in 'Physics' started by Ashley Reid, Oct 8, 2018.

  1. Ashley Reid

    Ashley Reid Guest

    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.

    [​IMG]

    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=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;}


    }

    Login To add answer/comment
     

Share This Page