- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you define the system timer in the system library properties?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No.
But somehow if I activate the timer, the system do nothing after flashing btw. I dont use an operating system System: Stratix III Board. Timerout period is 1µs and the timer is full featured- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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; }
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page