Hi everyone!
I have PORTB on a DSPIC 33F which is connected to two 8 bit DACs, one on PORTB 0-7 and the other on PORTB 8 - 15.
How can I directly access, with one intruction, the two halfs of the port as if they were two 8 bit ports?
Thank you very much!
Address half PORTB
Hi,
Can you specify what dsPIC33 are you using? This family of microcontrollers has 16-bit operations, so all assembly lines use 16-bit word operands, unless specified to use byte operands, by extending asm directives with .B suffixes. This means that if you write, for example:
assembly equivalent generated by the compiler would be:
Of course, you must use two assembly instructions to copy one 16-bit value from one register to another, by using W0 working register as a mediator. Only W registers can be copied directly in a single cycle with MOV commands, but other registers must be copied using two clock cycles.
If this is not the answer to your question, please rephrase and paste a piece of commented code that gives you trouble, and I'll do my best to help.
Best regards,
Aleksandar
Can you specify what dsPIC33 are you using? This family of microcontrollers has 16-bit operations, so all assembly lines use 16-bit word operands, unless specified to use byte operands, by extending asm directives with .B suffixes. This means that if you write, for example:
Code: Select all
unsigned int PORTVal;
void main(){
PORTVal = 0x0000;
PORTB = 0x1234;
PORTVal = PORTB;
}
Code: Select all
;void main(){
;PORTVal = 0x0000;
MOV #0, W0
MOV W0, _PORTVal
;PORTB = 0x1234;
MOV #4660, W0
MOV W0, PORTB
;PORTVal = PORTB;
MOV PORTB, W0
MOV W0, _PORTVal
If this is not the answer to your question, please rephrase and paste a piece of commented code that gives you trouble, and I'll do my best to help.
Best regards,
Aleksandar
Web Department Manager