This thread has been locked.

If you have a related question, please click the " Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Connect keypad using GPIO

Konstantin Doncov
Konstantin Doncov
Prodigy 230 points
Other Parts Discussed in Thread: LAUNCHXL-F28027, CONTROLSUITE

Hello!

I'm really new one here so sorry if I will ask some strange questions.

I have C2000 Piccolo LAUNCHXL-F28027 and 4x4 matrix keypad(like on the first attached image).

I want to connect keypad to F28027 using GPIO pins(which indicated on the second attached image) but get some issues:

  • What are the numbers of these pins(because I see some strange lettering "J2" and "J6")?
  • How can I access them from C code(like GPIO_setMode(myGpio, %NUMBER_OF_MY_GPIO_PIN%, GPIO_0_Mode_GeneralPurpose))?
  • How can I use PIE for interrupt when some key is pressed?

If you have any very simple code it will be very useful.

Thanks!

 

UPD:

void main(void)
{
    CPU_Handle myCpu;
    PLL_Handle myPll;
    WDOG_Handle myWDog;

    uint32_t TempX1Count;
    uint32_t TempX2Count;

    // Initialize all the handles needed for this application
    myClk = CLK_init((void *)CLK_BASE_ADDR, sizeof(CLK_Obj));
    myCpu = CPU_init((void *)NULL, sizeof(CPU_Obj));
    myFlash = FLASH_init((void *)FLASH_BASE_ADDR, sizeof(FLASH_Obj));
    myGpio = GPIO_init((void *)GPIO_BASE_ADDR, sizeof(GPIO_Obj));
    myPie = PIE_init((void *)PIE_BASE_ADDR, sizeof(PIE_Obj));
    myPll = PLL_init((void *)PLL_BASE_ADDR, sizeof(PLL_Obj));
    myWDog = WDOG_init((void *)WDOG_BASE_ADDR, sizeof(WDOG_Obj));

    // Perform basic system initialization
    WDOG_disable(myWDog);
    CLK_enableAdcClock(myClk);
    (*Device_cal)();

    //Select the internal oscillator 1 as the clock source
    CLK_setOscSrc(myClk, CLK_OscSrc_Internal);

    // Setup the PLL for x10 /2 which will yield 50Mhz = 10Mhz * 10 / 2
    PLL_setup(myPll, PLL_Multiplier_10, PLL_DivideSelect_ClkIn_by_2);

    // Disable the PIE and all interrupts
    PIE_disable(myPie);
    PIE_disableAllInts(myPie);
    CPU_disableGlobalInts(myCpu);
    CPU_clearIntFlags(myCpu);

    // If running from flash copy RAM only functions to RAM
#ifdef _FLASH
    memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize);
#endif

    // Setup a debug vector table and enable the PIE
    PIE_setDebugIntVectorTable(myPie);
    PIE_enable(myPie);

    // Register interrupt handlers in the PIE vector table
    PIE_registerPieIntHandler(myPie, PIE_GroupNumber_1, PIE_SubGroupNumber_4,
                              (intVec_t)&xint1_isr);
    PIE_registerPieIntHandler(myPie, PIE_GroupNumber_1, PIE_SubGroupNumber_5,
                              (intVec_t)&xint2_isr);

    // Clear the counters
    Xint1Count = 0; // Count XINT1 interrupts
    Xint2Count = 0; // Count XINT2 interrupts
    LoopCount = 0;  // Count times through idle loop

    // Enable XINT1 and XINT2 in the PIE: Group 1 interrupt 4 & 5
    // Enable INT1 which is connected to WAKEINT
    PIE_enableInt(myPie, PIE_GroupNumber_1, PIE_InterruptSource_XINT_1);
    PIE_enableInt(myPie, PIE_GroupNumber_1, PIE_InterruptSource_XINT_2);
    CPU_enableInt(myCpu, CPU_IntNumber_1);

    // Enable Global Interrupts
    CPU_enableGlobalInts(myCpu);


    // GPIO2 - GPIO5 are outputs
    GPIO_setLow(myGpio, GPIO_Number_2);
    GPIO_setMode(myGpio, GPIO_Number_2, GPIO_2_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio, GPIO_Number_2, GPIO_Direction_Output);

    GPIO_setLow(myGpio, GPIO_Number_3);
    GPIO_setMode(myGpio, GPIO_Number_3, GPIO_3_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio, GPIO_Number_3, GPIO_Direction_Output);


    GPIO_setLow(myGpio, GPIO_Number_4);
    GPIO_setMode(myGpio, GPIO_Number_4, GPIO_4_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio, GPIO_Number_4, GPIO_Direction_Output);

    GPIO_setLow(myGpio, GPIO_Number_5);
    GPIO_setMode(myGpio, GPIO_Number_5, GPIO_5_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio, GPIO_Number_5, GPIO_Direction_Output);

// GPIO0 and GPIO1 are inputs GPIO_setMode(myGpio, GPIO_Number_0, GPIO_0_Mode_GeneralPurpose); GPIO_setDirection(myGpio, GPIO_Number_0, GPIO_Direction_Input); GPIO_setMode(myGpio, GPIO_Number_1, GPIO_1_Mode_GeneralPurpose); GPIO_setDirection(myGpio, GPIO_Number_1, GPIO_Direction_Input); // GPIO0 is XINT1, GPIO1 is XINT2 GPIO_setExtInt(myGpio, GPIO_Number_0, CPU_ExtIntNumber_1); GPIO_setExtInt(myGpio, GPIO_Number_1, CPU_ExtIntNumber_2); // Configure XINT1 PIE_setExtIntPolarity(myPie, CPU_ExtIntNumber_1, PIE_ExtIntPolarity_RisingEdge); PIE_setExtIntPolarity(myPie, CPU_ExtIntNumber_2, PIE_ExtIntPolarity_RisingEdge); // Enable XINT1 and XINT2 PIE_enableExtInt(myPie, CPU_ExtIntNumber_1); PIE_enableExtInt(myPie, CPU_ExtIntNumber_2); for(;;) { asm(" NOP"); } } __interrupt void xint1_isr(void) { Xint1Count++; // Acknowledge this interrupt to get more from group 1 PIE_clearInt(myPie, PIE_GroupNumber_1); } __interrupt void xint2_isr(void) { Xint2Count++; // Acknowledge this interrupt to get more from group 1 PIE_clearInt(myPie, PIE_GroupNumber_1); }

 

  • Gautam Iyer
    0 Gautam Iyer
    Hi,

    You can find the schematics for the board here:
    C:\ti\controlSUITE\development_kits\C2000_LaunchPad\LAUNCHXL-F28027\HwDevPkg

    Secondly, sample code is available to realize External interrupt in controlSuite.

    Regards,
    Gautam
  • Konstantin Doncov
    0 Konstantin Doncov in reply to Gautam Iyer
    Thanks for your response! I opened LAUNCHXL-F28027-PinOut.xlsx in HwDevPkg and saw that: J6 pins 1-8 can be used via GPIO0-5(1-6 pin) and GPIO16-17(7-8 pin). So I compiled this test code:
    GPIO_setMode(myGpio, GPIO_Number_0, GPIO_0_Mode_GeneralPurpose);
    GPIO_setDirection(myGpio, GPIO_Number_0, GPIO_Direction_Output);
    GPIO_setHigh(myGpio, GPIO_Number_0);
    But this code only turned off one of the four LEDs. What have I done wrong?
  • Gautam Iyer
    0 Gautam Iyer in reply to Konstantin Doncov
    You need to copy paste the initial GPIO configuration in the sample code for all the required GPIOs.

    Regards,
    Gautam
  • Konstantin Doncov
    0 Konstantin Doncov in reply to Gautam Iyer
    Thanks! I'm almost done. Now I a bit changed the code of ExternalInterrupt sample(current code in the updated question, please check it) and I got next issue:
    this code increases Xint1Count and Xint2Count variables from the very beginning like due to the timer tick(but I don't use timers). And key pressing stops this increasing but I need the opposite - call xint1_isr and xint2_isr functions ONLY when keys was pressed. What have I done wrong now?
  • Gautam Iyer
    0 Gautam Iyer in reply to Konstantin Doncov
    I guess you need to reverse the detection logic. Check your external interrupt configuration, whether its responding to low to high or high to low pulse. Simply reverse the same.

    Regards,
    Gautam
  • Konstantin Doncov
    0 Konstantin Doncov in reply to Gautam Iyer
    Do you mean change rising edge to falling edge or vice versa by PIE_setExtIntPolarity()?
    If yes, then I already tried this - it's gives nothing.
  • Gautam Iyer
    0 Gautam Iyer in reply to Konstantin Doncov
    Ok...that's odd! In short what you're observing is without the key press your external interrupt count is increasing right? Can you share your logic?

    Regards,
    Gautam
  • Konstantin Doncov
    0 Konstantin Doncov in reply to Gautam Iyer
    >In short what you're observing is without the key press your external interrupt count is increasing right?
    Yes, exactly! And when I press some keys it stops increasing.
    >Can you share your logic?
    All logic which I already implemented in code I added in the my first question/post(it is marked as "UPD:"), and I think this error located in this code, so you can check it.
    If you need some extra info then I can provide it, but I should know what you exactly need(because I am very new here) :)
    Regards.
  • Gautam Iyer
    0 Gautam Iyer in reply to Konstantin Doncov
    Ok, can you check with this example code:
    C:\ti\controlSUITE\device_support\f2802x\v230\f2802x_examples_structs\external_interrupt

    In short implement in a stuctural way instead of driver.

    Regards,
    Gautam
  • Konstantin Doncov
    0 Konstantin Doncov in reply to Gautam Iyer
    Thanks, I tried this sample but it gives exactly the same result. Please check my new question: e2e.ti.com/.../481166
    Regards.
  • Gautam Iyer
    0 Gautam Iyer in reply to Konstantin Doncov
    That's really odd... there's something you tend to miss. Let me check the new thread.
    Btw I've tested these codes and I've used multiple push buttons to interface with 4 external interrupts. They worked like charm!

点石阅读奥运会女足直播起名属水的字有哪些姚姓男小孩起名大全动画片大全少儿全部免费咱俩饭店起名网书店一般起什么名字当快软件园101次抢婚易经中起名字好听起名网免费取名生辰八字打分心不在焉的拼音开店起名有什么讲究迷途英雄起个一起挣钱的群名大学生实习总结美容养生店起名字相亲平台起什么名字栩字起名男宝一起学猫叫的歌名叫什么黑魂3攻略给猫咪起名字英文八字缺金起名字大全中国灵异故事照本宣科的意思公司起名字大全免费两个字的小学教育辅导起名卢布兑人民币汇率12306火车票查询猪孩子宜用字起名公司起名字大师下载歼20紧急升空逼退外机英媒称团队夜以继日筹划王妃复出草木蔓发 春山在望成都发生巨响 当地回应60岁老人炒菠菜未焯水致肾病恶化男子涉嫌走私被判11年却一天牢没坐劳斯莱斯右转逼停直行车网传落水者说“没让你救”系谣言广东通报13岁男孩性侵女童不予立案贵州小伙回应在美国卖三蹦子火了淀粉肠小王子日销售额涨超10倍有个姐真把千机伞做出来了近3万元金手镯仅含足金十克呼北高速交通事故已致14人死亡杨洋拄拐现身医院国产伟哥去年销售近13亿男子给前妻转账 现任妻子起诉要回新基金只募集到26元还是员工自购男孩疑遭霸凌 家长讨说法被踢出群充个话费竟沦为间接洗钱工具新的一天从800个哈欠开始单亲妈妈陷入热恋 14岁儿子报警#春分立蛋大挑战#中国投资客涌入日本东京买房两大学生合买彩票中奖一人不认账新加坡主帅:唯一目标击败中国队月嫂回应掌掴婴儿是在赶虫子19岁小伙救下5人后溺亡 多方发声清明节放假3天调休1天张家界的山上“长”满了韩国人?开封王婆为何火了主播靠辱骂母亲走红被批捕封号代拍被何赛飞拿着魔杖追着打阿根廷将发行1万与2万面值的纸币库克现身上海为江西彩礼“减负”的“试婚人”因自嘲式简历走红的教授更新简介殡仪馆花卉高于市场价3倍还重复用网友称在豆瓣酱里吃出老鼠头315晚会后胖东来又人满为患了网友建议重庆地铁不准乘客携带菜筐特朗普谈“凯特王妃P图照”罗斯否认插足凯特王妃婚姻青海通报栏杆断裂小学生跌落住进ICU恒大被罚41.75亿到底怎么缴湖南一县政协主席疑涉刑案被控制茶百道就改标签日期致歉王树国3次鞠躬告别西交大师生张立群任西安交通大学校长杨倩无缘巴黎奥运

点石阅读 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化