blob: 9f62ab3c8333cd21bb5077881a9abbbf30da8fe6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#include <stdint.h>
#include <murax.h>
void main() {
volatile uint32_t a = 1, b = 2, c = 3;
uint32_t result = 0;
char msg[] = "Lieber Franz! Wir wünschen Dir eine gute Zeit!";
uint32_t msgidx = 0;
interruptCtrl_init(TIMER_INTERRUPT);
prescaler_init(TIMER_PRESCALER);
timer_init(TIMER_A);
TIMER_PRESCALER->LIMIT = 50000-1; //1 ms rate
TIMER_A->LIMIT = 1000-1; //1 second rate
TIMER_A->CLEARS_TICKS = 0x00010002;
TIMER_INTERRUPT->PENDINGS = 0xF;
TIMER_INTERRUPT->MASKS = 0x1;
GPIO_A->OUTPUT_ENABLE = 0x000000FF;
GPIO_A->OUTPUT = 0x00000000;
UART->STATUS = 2; //Enable RX interrupts
UART->DATA = 'A';
while(1){
result += a;
result += b + c;
for(uint32_t idx = 0;idx < 200000;idx++) asm volatile("");
if (msgidx == sizeof(msg)-1)
msgidx = 0;
else
msgidx++;
UART->DATA = msg[msgidx];
GPIO_A->OUTPUT = (GPIO_A->OUTPUT & ~0x3F) | ((GPIO_A->OUTPUT + 1) & 0x3F); //Counter on LED[5:0]
}
}
void irqCallback(){
if(TIMER_INTERRUPT->PENDINGS & 1){ //Timer A interrupt
GPIO_A->OUTPUT ^= 0x80; //Toogle led 7
TIMER_INTERRUPT->PENDINGS = 1;
}
while(UART->STATUS & (1 << 9)){ //UART RX interrupt
UART->DATA = (UART->DATA) & 0xFF;
}
}
|