Having trouble setting PORTD in assembly

I've been trying to solve this problem for the last few days and nothing has worked. When I code in assembly, I can turn on all ports except the D port. The port refuses to exit its High-Impedance mode. When I use the web compiler the port turns on without any problem. I figure posting raw assembly is useless, so here are my relevant register settings:

PORTD.PDR = 0xff (Port Direction)

PORTD.PODR = 0xff (Port Output Data Register)

PORTD.PMR = 0x00 (Port Mode Reg)

PORTD.ODR0 = 0x00 (Open Drain Cont0)

PORTD.ODR1 = 0x00 (Open Drain Cont1)

PORTD.PCR = 0x00 (Pull-up register)

PORTD.DSCR = 0xff (Drive Capacity Control register) (although this is shouldn't matter, as the load is only an led with a larger resistor)

PWPR = 0b01000000 (Write Protect register of the MPC)

PD[0-7]PFS = 0x00 (MPC Pin Function Control Register)

Anything not mentioned here I did not touch. Can someone see why PORTD is reluctant to work? I looked through the Web compiler's code and couldn't find anything else relevant. Did I overlook something?

I am grateful for absolutely any help.

  • Hi,

    I think the setting for external bus affects an operation for PORTD.
    If the below code is comment out, even the library of digitalWrite for PORTD doesn't work.
    So I think it's necessary to add below code into your code.

    // Stop external bus
    SYSTEM.SYSCR0.WORD = 0x5A01;
  • In reply to Okamiya Yuuki:

    Thanks a ton, that did the trick!