Ok, well. Dont know where is the bug. But anyway. I just use now directly the timer interrupt and I am configuring the registers directly as well. This is working pretty good. This solution fits perfectly for me.
So thx for help!
void main(){
IOWR(0x00000020,1,(1<<3) | (1 << 0) );//Stop Timer, IRQ enable, counter stops when getting 0
IOWR(0x20,0,0); // Clear TO Bit(Reaching 0)
IOWR(0x20,2,(alt_u16)(100000000-1)); // Clear TO Bit(Reaching 0);(100000000-1)=1s(100Mhz)
IOWR(0x20,3,(alt_u16)( (100000000-1) >> 16 )); // Clear TO Bit(Reaching 0)
alt_irq_register(TIMER_0_IRQ, NULL, timer_interrupt);
IOWR(0x00000020,1,(1<<2) | (1 << 0) );//Start Timer, IRQ enable, counter stops when getting 0}
return 0;
}
alt_u32 timer_interrupt(void* context)
{
IOWR(0x20,0,0); //Clear TO(timeout) bit)
IOWR(0x00000020,1,(1<<2) | (1 << 0) );//Start Timer, IRQ enable, counter stops when getting 0
printf("tick\n");
return 1;
}