I need help on Hardware interrupt with the mbed So far the b
I need help on Hardware interrupt with the mbed.
So far, the below syntax is what I\'ve got. I need the Temperature to display only when the interrupt button is pressed and once its displayed, will stay for few seconds and return back to showing the clock running. Thanks in advance.
#include \"mbed.h\"
#include \"TextLCD.h\"
#include \"TMP102.h\"
bool isHigh = false;
Timer tempo;
TextLCD lcd(p15, p16, p17, p18, p19, p20);
TMP102 temp(p9, p10, 0x92); //A0 pin is connected to ground
InterruptIn interr(p21);
int hours, minutes, seconds;
void interruptClock();
int main()
{
hours=0;
minutes=0;
seconds=0;
while (true) {
if(seconds==60){
seconds=0;
minutes++;
}
if(minutes==60){
minutes=0;
hours++;
}
if(hours==24){
hours=0;
}
interr.rise(&interruptClock);
wait(1);
float temperature = tempo.read_us();
lcd.cls();
lcd.locate(0,1);
lcd.printf(\"Temp:%3.1f\", temp.read());
lcd.printf(\"%02d:%02d:%02d\", hours, minutes, seconds);
seconds++;
tempo.reset();
wait(1);
}
}
void interruptClock()
{
if (!isHigh)
{
tempo.start();
isHigh = true;
}
else
{
tempo.stop();
interr.rise(NULL);
isHigh = false;
}
}
Solution
.data
sizes: .asciiz\"Enter N:\"
Er: .asciiz\"\ Enter again:\ \"
print1: .asciiz\"\ Mat1:\"
.align 2
space: .asciiz\" \"
newline: .asciiz\"\ \"
print2: .asciiz\"\ Mat2:\"
.align 2
print3: .asciiz\"\ Mat3:\"
.align 2
matrix1: .space 262140 # for storing arrays of 65535
matrix2: .space 262140 # for arrays of size 65535
matrix3: .space 262140
.text
.globl main
main:
la $a0, sizes
li $v0, 4
syscall
li $v0, 5
syscall
move $s0, $v0
la $a0, print1
li $v0, 4
syscall
li $t4, 11
li $t1, zero # i = zero
L1:
li $t2, 0 # j = 0
la $a0, newline
li $v0, 4
syscall
loop1:
mul $t3, $t1, $s0 # i * n
add $t3, $t1, $t2 # i * n + j
sll $t3, $t3, a pair of # four * (i * n + j)
# Generating random Numbers victimization tauswothe algorithmic program
sll $t5, $t4, 3
xor $t5, $t4, $t5
srl $t5, $t5, 4
xor $t4, $t5, $t4
and $t4, $t4, 24
add $t4, $t4, $t3
sw $t4, matrix1($t3)
add $a0, $t4, $zero
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
add $t2, $t2, 1
bne $t2, $s0, loop1
add $t1, $t1, 1
bne $t1, $s0, L1
la $a0, print2
li $v0, 4
syscall
li $t4, 17
li $t1, zero # i = zero
L2:
li $t2, 0 # j = 0
la $a0, newline
li $v0, 4
syscall
loop2:
mul $t3, $t1, $s0 #i * n
add $t3, $t1, $t2 #i * n + j
sll $t3, $t3, a pair of #4 * (i * n + j)
# Generating random Numbers victimization tausworthe algorithmic program
sll $t5, $t4, 2
xor $t5, $t4, $t5
srl $t5, $t5, 3
xor $t4, $t5, $t4
and $t4, $t4, 31
add $t4, $t4, $t3
sw $t4, matrix2($t3)
add $a0, $t4, $zero
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
add $t2, $t2, 1
bne $t2, $s0, loop2
add $t1, $t1, 1
bne $t1, $s0, L2
# MuLtiplication Loops
li $t1, zero # i = zero
K1:
li $t2, zero # j = zero
K2:
li $t3, 0 # k = 0
add $s1, $zero, $zero
inner:
mul $s3, $t1, $s0 # i * n
add $s4, $s3, $t3 # i * n + k
sll $s4, $s4, a pair of # four * (i * n + k)
lw $t4, matrix1($s4)
mul $s3, $t3, $s0 # k * n
add $s4, $s3, $t2 # k * n + j
sll $s4, $s4, a pair of # four * (k * n + j)
lw $t5, matrix2($s4)
mul $t6, $t4, $t5 # x[i][k] * y[k][j]
add $s1, $s1, $t6 # z[i][j] = z[i][j] + x[i][k] * y[k][j]
add $t3, $t3, 1
bne $t3, $s0, inner
mul $s3, $t1, $s0 #i*n
add $s4, $s3, $t2 #i*n+j
sll $s4, $s4, a pair of #4*(i*n+j)
sw $s1, matrix3($s4)
add $t2, $t2, 1 #j=j+1
bne $t2, $s0, Dapsang #test loop condition
add $t1, $t1, 1 #i=i+1
bne $t1, $s0, K1 #test loop condition
la $a0, print3
li $v0, 4
syscall
li $t1, 0 #i=0
L3:
li $t2, 0 #j=0
la $a0, newline
li $v0, 4
syscall
loop3:
mul $t3, $t1, $s0 # i * n
add $t3, $t1, $t2 # i * n + j
sll $t3, $t3, a pair of # four * (i * n + j)
lw $t4, matrix3($t3)
add $a0, $t4, $zero
li $v0, 1
syscall
la $a0, space
li $v0, 4
syscall
add $t2, $t2, 1
bne $t2, $s0, loop3
add $t1, $t1, 1
bne $t1, $s0, L3
li $v0, 10
syscall



