RX63N setting MPC


I am trying to implement the RSPI in RX63N. However it is not working, so far i have noticed that I am unable to set the MPC correctly (write protection is handled). Writing into MPC only sets every fourth register, here part of my code and the results:


#define MPC_PA4F        (*((volatile uint32_t *)        (0x0008C194)))  //Port A Pin 4 Function Register
#define MPC_PA5F        (*((volatile uint32_t *)        (0x0008C195)))  //Port A Pin 5 Function Register
#define MPC_PA6F        (*((volatile uint32_t *)        (0x0008C196)))  //Port A Pin 6 Function Register
#define MPC_PA7F        (*((volatile uint32_t *)        (0x0008C197)))  //Port A Pin 7 Function Register


  MPC_WPR &= ~(1<<7);
  MPC_WPR |= (1<<6);
  MPC_PA4F |= (1<<3 | 1<<2 | 1<<0);             //equals 0x0D
  MPC_PA5F |= 0x0D;
  MPC_PA6F |= 0x0D;
  MPC_PA7F |= 0x0D;
  MPC_WPR &= ~(1<<6);
  MPC_WPR |= (1<<7);

When checking the registers after the code being executed, 0x0008C194 to 0x0008C196 still have the value 0, while only 0x0008C197 has the value 0x0D. It should be noted though, that 0x0008C197 is already being set to 0x0D when writing this value to 0x0008C194. Same goes for setting every other of these registers independently. Only when setting 0x0008C193 (not used here), it writes to 0x0008C193, writing to 0x0008C190 - 0x0008C193 sets only register 0x0008C193 again though.

I also checked the disassembly, it displays the correct addresses:

  --MPC_PA4F |= (1<<3 | 1<<2 | 1<<0);             //writes into xx197...(instead of xx194)
 FFF00427   FB 1E 94 C1    MOV        #0x08C194:24,R1
 FFF0042C   EC 12          MOV.L      [R1],R2
 FFF0042E   65 D2          OR         #0x0D:4,R2
 FFF00430   FB 1E 94 C1    MOV        #0x08C194:24,R1
 FFF00435   E3 12          MOV.L      R2,[R1]
  --MPC_PA5F |= 0x0D;
 FFF00437   FB 1E 95 C1    MOV        #0x08C195:24,R1
 FFF0043C   EC 12          MOV.L      [R1],R2
 FFF0043E   65 D2          OR         #0x0D:4,R2
 FFF00440   FB 1E 95 C1    MOV        #0x08C195:24,R1
 FFF00445   E3 12          MOV.L      R2,[R1]

Status of the registers after writing:

 0008C194   00             BRK
 0008C195   00             BRK
 0008C196   00             BRK
 0008C197   0D             BRA.S      0x8C19C

I hope someone can tell me what I am doing wrong here. Thank you in advance.

EDIT: It seems I accidentally posted this to "Bluetooth". I am sorry about this mistake, but I dont see an option available to erase/move this post.

  • You are casting the addresses to uint32_t so it can be clearly seen in the assembly it uses a mov.l R2,[r1]

    Try casting the address to uint8_t hopefully then it will use mov.b


  • Why don't you use 'iodefine.h' (RENESAS I/O resources definition)? It helps avoid simple errors like this and speed-up development process.

  • In reply to Jan Dupek:

    Because it is my first time working with a Renesas controller and I did not know about this. But thank you for telling me.

    EDIT: Looked it up now, apparently it is a file generated by the HEW IDE, but im using IAR

  • I'd suggest e2studio with Renesas CC-RX compiler package. I work wit it for more than one year. It is optimized for RX-family, very reliable.

  • Hi,

    You are defining the MPC registers as pointers to four byte words. Of course it will only write to every fourth register. The MPC registers are one byte only. Change it to e.g.

    #define MPC_PA4F        (*((volatile uint8_t*)        (0x0008C194)))

    Why don't you use the Renesas or IAR iodefine.h file?