Altera_Forum
Honored Contributor
16 years agoalt_alarm_start doesnt work
Here is my code:
# include <stdio.h># include <stdlib.h># include <stddef.h># include "system.h"# include "IO.h"# include "sys/alt_alarm.h"# include "alt_types.h" /*Prototypes*/ alt_u32 timer_interrupt(void* context); int alt_alarm_start(alt_alarm* alarm, alt_u32 nticks, alt_u32 (*callback) (void* context), void* context); /*Global Variables*/ static alt_alarm alarm; void main(){ printf("alt_sysclk_init: %d\n",alt_sysclk_init(TIMER_0_TICKS_PER_SEC)); //This is an edit. looks like I need that. With that alt_alarm_start works. Just dont get an interrupt. if(alt_alarm_start(&alarm,1000,timer_interrupt,NULL) < 0) alt_printf("No system clock available\r\n"); } alt_u32 timer_interrupt(void* context) { printf("tick\n"); return 1; } Where is the bug? I am running with "hello_world_small"(Must save memory). Looks like the alt_alarm_start fucntion return nothing(Null) -> get the "No system clock available" message. EDIT: I am running with the timer and not just with CPU-ticks, or?