NIOS II Blinking LEDs

Clock: 125 MHz = 8 ns
Sleep: 8 ns * 125 = 1 us
void sleep_ms(int milisec)
{
    int i;
    int k;
    for (i = 0; i < milisec; i++) {
        for (k = 0; k < 125; k++) {
             __asm("nop");
        }
    }
}

int
main()
{    
    int i = 0;
    int k = 0;
    while (1) {
        k = 1 << i;
        i++;
        av_bus_write_32(HOST_REG_USER0, k);
        sleep_ms(5);
        if (i > 4) {
            i = 0;
        }
    }
    
    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *