how to generate many square wave signals using StartKit

All technical discussions and projects around startKIT
quyenhuynh
Member
Posts: 12
Joined: Thu Dec 22, 2016 9:36 am

how to generate many square wave signals using StartKit

Postby quyenhuynh » Sun Jan 01, 2017 10:54 am

I am joining a project as HuyPham researching in topic : http://www.xcore.com/forum/viewtopic.ph ... it=MA40s4s. I have generated 8 square waves with code as in topic. But I encountered the problems as:
1/ Why can not I generate wave on pins 4 bit, 8bit or 32bit differently that code only working on pins a bit (1F,1J...)
2/ How to generate many square waves on startKit (about 50 waves with each wave have different phase delay).
I am a new programming and finding out about how to working as well as programming of startKit so I very need help from everyone.
thanks all
quyenhuynh
Member
Posts: 12
Joined: Thu Dec 22, 2016 9:36 am

Postby quyenhuynh » Mon Jan 02, 2017 3:37 am

Thanks @mon2, Could you give me how to "wider port by linking tiles together" to develop the below code which can work on 50 pins of startKIT

Code: Select all

#include <xs1.h>

port p0 = XS1_PORT_1E;
port p1 = XS1_PORT_1F;
port p2 = XS1_PORT_1G;
port p3 = XS1_PORT_1H;
port p4 = XS1_PORT_1I;
port p5 = XS1_PORT_1J;
port p6 = XS1_PORT_1K;
port p7 = XS1_PORT_1D;

void forty(port p, unsigned short edge_clk_cnt) {
    for(int i = 0; i < 100; i++) {
        p @ edge_clk_cnt <: 0;
        edge_clk_cnt += 1250;
        p @ edge_clk_cnt <: 1;
        edge_clk_cnt += 1250;
    }
}


int main(void) {
    while(1) {
        unsigned short phase0 = (2500 * 0)/360;
        unsigned short phase1 = (2500 * 10)/360;
        unsigned short phase2 = (2500 * 20)/360;
        unsigned short phase3 = (2500 * 30)/360;
        unsigned short phase4 = (2500 * 40)/360;
        unsigned short phase5 = (2500 * 50)/360;
        unsigned short phase6 = (2500 * 60)/360;
        unsigned short phase7 = (2500 * 70)/360;



        unsigned int current;

            p0 <: 0 @ current;
            current += 5000;
            par {
                forty(p0, phase0 + current);
                forty(p1, phase1 + current);
                forty(p2, phase2 + current);
                forty(p3, phase3 + current);
                forty(p4, phase4 + current);
                forty(p5, phase5 + current);
                forty(p6, phase6 + current);
                forty(p7, phase7 + current);



                 }
}
    return 0;
}



Return to “startKIT”

Who is online

Users browsing this forum: No registered users and 4 guests