assembly - Bank switching in PIC assembler -
I am confused by switching the bank in PIC codele ... it works to put 'Q' on the user :
BSF PORTB, 1; Set Transmit DIR (Port B (0x6) is not reflected in other banks) movlw 'Q'; 'Q' to RAM movwf TXREG; TXREG (0x19) to work is not mirrored in other banks) Clear Watchdog BTFS TXSTA, TRMT; Wait for 'Q' to move (TXSTA is 0x18, not mirror) Goto $ 2BCF PORTB, 1; Set Devier DIR And it works just as well:
BCF 0x3, 0x5; Switch to bank 0 BCF 0x3, 0x6 BSF Portab, 1; Transmitted DIR movlw 'Q'; Q 'to work RAGMF TXREG; TCREG BSF 0x3, 0x5; Switch to BRF 0x5; Chekede BSTSTSTSTA, TRMT; Rupee. Rupee.' Q $ 2 BCF 0x3, 0x5; Switch to bank 0 BCF PORTB, 1; Set ADD DIR I have checked that the compiler does not switch any bank when I do not see ... when to change the bank?
The peak device you are using first, because it makes a difference. Also the compiler is also using you.
However, your code works, so whatever you have to do for TX in UART, it is in Bank 0. You do not have to write anything in Port B which I am guessing that you want to switch truss and it is in 1 bank, but since the UAR controls the pins on the ports, there is no effect of its own. In your second example you are voting which you think is the TXSTA, but it is not a bank in the bank 1. I guess you can be lucky by voting at the wrong place and the bit is always in the right position, so The loop ends.
When I make a transmittance, I have to first see that the UAR is empty and till it does not wait and then send it to four. There is no need to wait to complete this transmittance, unless you want to use an interface for example to get the next letter.
Therefore, both pieces of code work because you both are in Bank 0 when you do movwf TXREG. The rest is handled in the hardware for you.
Edit: Now that I know that the correct part of the TSTTA is in Bank 1. You should be through me because the comment of your address was as 0x18 and should be 0x98 In the first example you are voting RCSTA bit 1 which is not OARR TACSTA. So if this is working then it means that OARR = 1 is very possible, I usually do anything when getting it while clearing it.
Comments
Post a Comment