Greetings! I am lost; I think my program is too!
Here is the code snip:
<snip>
interrupt void c_int11() {
// collect samples
short sample_data; // variable that stores the current sample
short output; // output variable for processed sample
if (program_control == 0) {
sample_data = input_left_sample();
if (sample_data > threshold) signal_on = 1;
if (signal_on) {
if (column_index < column_len) {
data_buffer.data[row_index][column_index].real = filter_signal(sample_data);
column_index++;
}
if ( (row_index < row_len) && (column_index >= column_len) ) {
row_index++; // increment row index by 1
column_index = 0; // reset column index back to 0
//printf("collecting frame number: %d\n", row_index);
}
}
}
if (row_index >= row_len) program_control = 1; // move to next state
// collect samples
// playback
if (program_control == 1) {
output = playback();
output_sample(output);
if ( (output == 0) && (row < row_len) && (zero_count_flag == 0) ) {
zero_count++;
/*****************************************************************
* row >= (row_len - 1) because playback() increments row_len will
* at the end of its process.
*****************************************************************/
if (row >= (row_len - 1) ) {
printf ("Counted %d zeros in collected samples.\n", zero_count);
zero_count_flag = 1;
}
}
}
// playback
return;
}
<snip>
Here is my problem. I have a simple while loop in main():
while (program_control == 0);
My understanding is that while the statement is true, the CPU will check interrupts and run my code. Is that wrong? It must be because nothing is happening.
Here is my Vectors_intr.asm file:
<begin file>
*Vectors_intr.asm Vector file for interrupt INT11
.global _vectors ;global symbols
.global _c_int00
.global _vector1
.global _vector2
.global _vector3
.global _vector4
.global _vector5
.global _vector6
.global _vector7
.global _vector8
.global _vector9
.global _vector10
.global _c_int11 ;for INT11
.global _vector12
.global _vector13
.global _vector14
.global _vector15
.ref _c_int00 ;entry address
VEC_ENTRY .macro addr ;macro for ISR
STW B0,*--B15
MVKL addr,B0
MVKH addr,B0
B B0
LDW *B15++,B0
NOP 2
NOP
NOP
.endm
_vec_dummy:
B B3
NOP 5
.sect ".vectors" ;aligned IST section
.align 1024
_vectors:
_vector0: VEC_ENTRY _c_int00 ;RESET
_vector1: VEC_ENTRY _vec_dummy ;NMI
_vector2: VEC_ENTRY _vec_dummy ;RSVD
_vector3: VEC_ENTRY _vec_dummy
_vector4: VEC_ENTRY _vec_dummy
_vector5: VEC_ENTRY _vec_dummy
_vector6: VEC_ENTRY _vec_dummy
_vector7: VEC_ENTRY _vec_dummy
_vector8: VEC_ENTRY _vec_dummy
_vector9: VEC_ENTRY _vec_dummy
_vector10: VEC_ENTRY _vec_dummy
_vector11: VEC_ENTRY _c_int11 ;ISR address
_vector12: VEC_ENTRY _vec_dummy
_vector13: VEC_ENTRY _vec_dummy
_vector14: VEC_ENTRY _vec_dummy
_vector15: VEC_ENTRY _vec_dummy
<end file>
Now, I don't claim to understand the assembly that's in this file. But I have read up on some other posts and made the requested changes with no success. I have also combed through some of the documentation and the Chassaing book and I still don't understand.
Could someone please help me understand how to properly execute an ISR with my code?
For background, here is what I think is going on:
+ I also have another variable that is declared as such `#define DEBUG <val>' .
. When DEBUG was in c_int11(), I got my samples and everything ran nice. As soon as I took DEBUG out of the ISR, nothing worked.
+ This tells me that even though program_control is initialized to 0 and stays at 0, the ISR is never fired.
+ Obviously, I need to figure out how to check the appropriate registers, but I am not sure which ones to check and the IDE documentation is confusing to me.
. I think I understand _why_ it's not working, I just don't understand _how_ to fix it.
Thank you for reading.