”かふぇルネ“はルネサス製品に関してユーザ同士が自由に会話をするツールであり、回答者はルネサス社内外の方たちとなります。ルネサス製品やソリューションに関して正式な回答をご希望の場合は、ルネサス技術サポート問合せをご使用ください。

User button is not working?

There are 6 buttons connected with the microcontroller RL/G14, All the buttons are connected to port2. I want to read the buttons and perform the certain functions as if the mode button is pressed clear the screen but I could not read the button writing code as  below:

How can I clear the screen?

 In the switch.c

#include<stdio.h>

unsigned char modef = 0;                           //switch flag
unsigned char upf = 0;
unsigned char downf = 0;
unsigned char leftf = 0;
unsigned char rightf = 0;
unsigned char setf = 0;


void op_switich_in(void)
{
unsigned char opsw_id;

opsw_id = op_swin_1d();                              //reading the switch data

                           if (opsw_id == before_opsw_id){
                           if ((opsw_id & 0x01) == 0) modef = 1;
                           if ((opsw_id & 0x02) == 0) upf = 1;
                           if ((opsw_id & 0x04) == 0) downf = 1;
                           if ((opsw_id & 0x08) == 0) leftf = 1;
                           if ((opsw_id & 0x10) == 0) rightf = 1;
                           if ((opsw_id & 0x20) == 0) setf = 1;
                }
              before_opsw_id = opsw_id;

                 } 

unsigned char op_swin_1d(void)
{
                     unsigned char swid;

                    P0 = P0 | 0x20; 
                    delay_micro(100); 
                    swid = P2 & 0x3F;
                    P0 = P0 & 0xDF;
 
                     return swid;
}

  • Hi, hensal san. This is choko.

    Is this all of your program?

    From where op_switich_in is called ? And what timing op_switich_in is called ? 

    Also what is relation  between the screen and RL787G14? 

    Please make above items clear.

  • all are called in button.h file as:


    void op_switich_in(void);
    unsigned char op_swin_1d(void);

    extern unsigned char modef;
    extern unsigned char upf;
    extern unsigned char downf;
    extern unsigned char leftf;
    extern unsigned char rightf;
    extern unsigned char setf;

    The screen is of the LCD screen, I want to perform some function pressing those buttons.

    but I do not know how to take input for the user button and use those inputs to display in output in lcd.

    All the buttons are connected to PORT2 and the pin for those buttons are P20, P21, P22, P23, P24, P25 respectively.

    How to read the buttons as input?

  • This is choko.

    >The screen is of the LCD screen, I want to perform some function pressing those buttons.

    >but I do not know how to take input for the user button and use those inputs to display in output in lcd.

    You want use simulator isn't it??

    Is the LCD screen for debugger?

    Basically RL78/G14 does not have LCD control function. How do you connect it to RL78/G14?

    Please make clear your system configuration.

  • This is choko.

    I want to know the hardware that you are using.