new timer

This commit is contained in:
2026-03-01 17:16:44 +01:00
parent 7b46ae5e87
commit abe0668787
19 changed files with 381 additions and 155 deletions

View File

@@ -6,7 +6,9 @@ static volatile uint32_t * const LEDS = (volatile uint32_t *)(GPIO_BASE+4)
static volatile uint32_t * const LEDGR = (volatile uint32_t *)(GPIO_BASE+8);
#define TIMER_BASE 0x40010000u
static volatile uint32_t * const TIMER = (volatile uint32_t *)(TIMER_BASE+0);
static volatile uint32_t * const TIMER_CNT = (volatile uint32_t *)(TIMER_BASE+0);
static volatile uint32_t * const TIMER_LD = (volatile uint32_t *)(TIMER_BASE+4);
static volatile uint32_t * const TIMER_ACK = (volatile uint32_t *)(TIMER_BASE+8);
#define MSTATUS_MIE (1u << 3)
#define MIE_MTIE (1u << 7)
@@ -25,21 +27,21 @@ static inline void irq_init() {
}
void timer_isr(){
static int set = 0;
*TIMER = 1840000*8;
*TIMER_ACK = 1;
*LEDGR = ~(*LEDGR);
}
void main(){
irq_init();
*LEDGR = 3;
*TIMER = 1840000*2;
*LEDGR = 1;
*TIMER_LD = 2 * 15000000/1000;
for(;;){
for(int i=1000; i<10000; i++){
for(int i=1000; i<10000; i+=10){
*R_FREQ = i;
for(int j=0; j<80; j++) asm volatile("nop");
*LEDS = i>>4;
// for(int j=0; j<80; j++) asm volatile("nop");
}
}
}