SamanthaL
Junior Member level 2
Hello everyone!
I'm getting a really weird error from my code and I can't figure out where its coming from! Below is a snippet of my code. I've been commenting out a lot of stuff to try and isolate this error. Below is the code that I believe is executing. (If it isn't, I can't find why!)
Start
;goto Debug ; Debugging code
clrf TRISB ; Make PORTB pins all outputs
clrf PORTB ; Clear PORTB outputs
clrf TRISD ; Make PORTD pins all outputs
clrf PORTD ; Clear PORTD outputs
clrf Test_Count ; Counter of test cases - start at 0
clrf Test_Case ; Stores 8 bits of test case - start at 0
MOVLF b'00000011', TRISC ;Set I/O for port C
Generate_Test_Cases
movf b'11111111', W
movwf Test_Case
bsf PORTC,6 ; MC code is 01
bcf PORTC,2 ; MC now ready to send data
; DEBUGGING CODE
goto MC_Transmission_Ready
MC_Transmission_Ready
movf Test_Case, W
movwf PORTD
goto Wait
bsf PORTC,2 ; MC code is now 10
bcf PORTC,6 ; MC ready for data from FPGA
goto Contact_FPGA
etc...
The above code should just turn on all the LED's. Instead of 1111, I'm getting 0100. (I'm only looking at the first 4 bits because I only have 4 LED's.) Can you see where this output is coming from? I thought for a while that the Contact FPGA subroutine was the source of the problem, but I commented it out and jumped over it and am still getting weird stuff. Please help!
The original code and screenshot of the config bits is attached.
Thanks everyone for your time!
I'm getting a really weird error from my code and I can't figure out where its coming from! Below is a snippet of my code. I've been commenting out a lot of stuff to try and isolate this error. Below is the code that I believe is executing. (If it isn't, I can't find why!)
Start
;goto Debug ; Debugging code
clrf TRISB ; Make PORTB pins all outputs
clrf PORTB ; Clear PORTB outputs
clrf TRISD ; Make PORTD pins all outputs
clrf PORTD ; Clear PORTD outputs
clrf Test_Count ; Counter of test cases - start at 0
clrf Test_Case ; Stores 8 bits of test case - start at 0
MOVLF b'00000011', TRISC ;Set I/O for port C
Generate_Test_Cases
movf b'11111111', W
movwf Test_Case
bsf PORTC,6 ; MC code is 01
bcf PORTC,2 ; MC now ready to send data
; DEBUGGING CODE
goto MC_Transmission_Ready
MC_Transmission_Ready
movf Test_Case, W
movwf PORTD
goto Wait
bsf PORTC,2 ; MC code is now 10
bcf PORTC,6 ; MC ready for data from FPGA
goto Contact_FPGA
etc...
The above code should just turn on all the LED's. Instead of 1111, I'm getting 0100. (I'm only looking at the first 4 bits because I only have 4 LED's.) Can you see where this output is coming from? I thought for a while that the Contact FPGA subroutine was the source of the problem, but I commented it out and jumped over it and am still getting weird stuff. Please help!
The original code and screenshot of the config bits is attached.
Thanks everyone for your time!