I'm using the following code to set PORTD4 and PORTD5 as outputs:
VPORTD.DIR |= (1<<4); VPORTD.DIR |= (1<<5);
This works as expected. When I change the code to
PORTD.DIRSET = (1<<4); VPORTD.DIR |= (1<<5);
then only PORTD5 is set as output. When I print the value of PORTD.DIR, it shows 0x20. I have no idea why this happens.
Edit:
when I insert a nop, the problem is going away:
PORTD.DIRSET = (1<<4); _NOP(); VPORTD.DIR |= (1<<5);