RL78G13 R5F1006 20-pin using P121/P122 in GPIO input mode?

Based on the manual for RL78/G13 by default when the MCU resets P121 and P122 (where you normally connect an oscillator) are set to GPIO input mode.
Using the applilet3 code generator in e2 studio I confirm that it does not set any of the bits in the Clock Operation Mode Control Register (CMC) that would disable the GPIO.

/***********************************************************************************************************************
* Function Name: R_CGC_Create
* Description  : This function initializes the clock generator.
***********************************************************************************************************************/
void R_CGC_Create(void)
{
    /* Set fMX */
    CMC = _00_CGC_HISYS_PORT | _00_CGC_SYSOSC_DEFAULT;
    MSTOP = 1U;
    /* Set fMAIN */
    MCM0 = 0U;
    OSMC = _10_CGC_RTC_CLK_FIL;
    /* Set fIH */
    HIOSTOP = 0U;
}

However when I connect either of the pins to VCC it never registers a high on P12.
This is in a 3.3V VCC system.

Is there a special configuration that is needed to use these pins in GPIO input mode?

According to the manual (R01UH0146EJ0340 Rev.3.40) page 230 I can also set EXCLK bit in CMS to 1 and that should also allow for GPIO input mode. I changed this in the generated code (to insure only write once) and it did not make any difference in the behavior.

The manual section Pin Block Diagram for Pin Type 2-2-1 (page 98) seems to imply that GPIO mode isn't included in the block if I am reading the diagram correctly. (Other blocks show GPIO separately)

Bill

  • Hi Bill,

    How's this issue? Have you figured out this already? The manual says they can be used as inputs. How do you read these pins in your code?

    JB
    RenesasRulz Forum Moderator

    https://renesasrulz.com/
    https://academy.renesas.com/
    https://en-us.knowledgebase.renesas.com/

  • In reply to JB:

    I still haven't gotten this to work.
    I have verified also that when selecting P121 and P122 in the code generator that it doesn't generate any specific code for these pins, but the code generator does recognize that I selected them, as it shows the warning mark in the GCG section showing the pins are already used.

    /********************************************************************************
    * File Name : r_cg_port.c
    * Version : CodeGenerator for RL78/G13 V2.05.03.01 [12 Nov 2018]
    * Device(s) : R5F1006E
    * Tool-Chain : GCCRL78
    * Description : This file implements device driver for PORT module.
    * Creation Date: 1/31/2020
    ********************************************************************************/
    void R_PORT_Create(void)
    {
    P0 = _00_Pn0_OUTPUT_0;
    P1 = _00_Pn0_OUTPUT_0;
    P2 = _00_Pn2_OUTPUT_0;
    P14 = _00_Pn7_OUTPUT_0;
    POM1 = _80_POMn7_NCH_ON;
    PMC0 = _00_PMCn0_DI_ON | _02_PMCn1_NOT_USE | _FC_PMC0_DEFAULT;
    PMC14 = _00_PMCn7_DI_ON | _7F_PMC14_DEFAULT;
    ADPC = _03_ADPC_DI_ON;
    PM0 = _00_PMn0_MODE_OUTPUT | _02_PMn1_NOT_USE | _FC_PM0_DEFAULT;
    PM1 = _00_PMn0_MODE_OUTPUT | _02_PMn1_NOT_USE | _04_PMn2_NOT_USE | _40_PMn6_NOT_USE | _80_PMn7_NOT_USE |
    _38_PM1_DEFAULT;
    PM2 = _01_PMn0_NOT_USE | _02_PMn1_NOT_USE | _00_PMn2_MODE_OUTPUT | _F8_PM2_DEFAULT;
    PM14 = _00_PMn7_MODE_OUTPUT | _7F_PM14_DEFAULT;
    }

    I try to read the pins this way and also look at the port register in the debugger, but the P12 port never changes when I hook either pin to 3.3V.
    if((P12 & _02_Pn1_OUTPUT_1) == 1) {
    ConsolePrintf("H ");
    } else {
    ConsolePrintf("L ");
    }

    if((P12 & _04_Pn2_OUTPUT_1) == 1) {
    ConsolePrintf("H");
    } else {
    ConsolePrintf("L");
    }

    Bill
  • In reply to Bill:

    Hi Bill,

    I don't see Port mode registers (PM12) and Port mode control register (PMC12) configured for input mode in the code for P121 and P122 pins. So, if you haven't configured them elsewhere, please do so before you can read the input from both pins P121 and P122.

    Neelima
  • In reply to Neelima:

    There is no PM12 or PMC12 setting for ports P121 and P122.
    If external clock is used on X1 and X2 ports P121 and P122 are not available.
    If external clock is not used the ports are input ports and can be read.
    If you have a debugger I would have a look at the register window to see the value of P121 and P122.
  • In reply to FrankL:

    I have confirmed on this part that you cannot write to the addresses where PM12 and PMC12 would be. You will get an exception and the value shown in RAM viewer will still be 0xFF.

    However I must have had some weird HW problem before or a bad connection on the last board that I tested.
    On the board currently on my desk I am now seeing the pin change in the debugger and I can read the pins as below for reference.

    if((P12 & _02_Pn1_OUTPUT_1) == _02_Pn1_OUTPUT_1) {
    // high
    }

    if((P12 & _04_Pn2_OUTPUT_1) == _04_Pn2_OUTPUT_1) {
    // high
    }