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.

Integrating TIVA C TM4C123G Launch Pad with active high PIR Sensor.

Other Parts Discussed in Thread: L293D

Hello Guys. Guys I am facing some issues regarding the integration of my TIVAC TM4C123G  Launchpad with active PIR Sensor. Here is my code.  There is no output at all on pin 2 PE2. even I checked the PIR output which was one.Actually I want to make an automatic door opener from it. Also I am facing trouble connecting DC motor of 5V with it. I assigned the output to logic one but the motor didn't turn on. Do ineed a L293D driver to operate it even in the single direction.? Please help..

#define SYSCTL_RCGCGPIO_R (*((volatile unsigned long*) 0x400FE608))

#define NVIC_EN0_R (*((volatile unsigned long*) 0xE000E100))
#define NVIC_PRI7_R (*((volatile unsigned long*) 0xE000E41C))


#define GPIO_PORTE_DATARd1_R (*((volatile unsigned long*) 0x40024008)) //PE1 for PIR1 in
#define GPIO_PORTE_DATAWr1_R (*((volatile unsigned long*) 0x40024010)) //PE2 for PIR1 out
#define GPIO_PORTE_DATARd2_R (*((volatile unsigned long*) 0x40024020)) //PE3 for PIR2 in
#define GPIO_PORTE_DATAWr2_R (*((volatile unsigned long*) 0x40024040)) //PE4 for PIR2 out
#define GPIO_PORTE_PDU_R (*((volatile unsigned long*) 0x40024514))
#define GPIO_PORTE_DIR_R (*((volatile unsigned long*) 0x40024400))
#define GPIO_PORTE_DEN_R (*((volatile unsigned long*) 0x4002451C))
#define GPIO_PORTE_AFSEL_R (*((volatile unsigned long*) 0x40024420))

#define GPIO_PORTE_IS_R (*((volatile unsigned long*) 0x40024404))
#define GPIO_PORTE_IBE_R (*((volatile unsigned long*) 0x40024408))
#define GPIO_PORTE_IEV_R (*((volatile unsigned long*) 0x4002440C))
#define GPIO_PORTE_IM_R (*((volatile unsigned long*) 0x40024410))
#define GPIO_PORTE_ICR_R (*((volatile unsigned long*) 0x4002441C))


#define PORTE_CLK_EN 0x10
#define INT_PE1 0x02
#define INT_PE3 0x08
#define NVIC_EN0_INT30 0x40000000


void Delay(long value);
void GPIOPortE_Handler(void);
void EnableInterrupts(void);
void DisableInterrupts(void);
void WaitForInterrupt(void);

#include "gpio.h"

void init_INT_GPIO(void)
{

DisableInterrupts();
SYSCTL_RCGCGPIO_R |= PORTE_CLK_EN;

GPIO_PORTE_DEN_R |=0x1E;
GPIO_PORTE_DIR_R &=~(0xA); //port E pin 1,3 for input of PIR
GPIO_PORTE_DIR_R |=0x14; //port E pin 2,4 for output to drive motor
GPIO_PORTE_AFSEL_R |=0xA;
NVIC_PRI7_R = 0x00A00000;
NVIC_EN0_R = NVIC_EN0_INT30;
DisableInterrupts();
GPIO_PORTE_IS_R &= ~(INT_PE1);
GPIO_PORTE_IBE_R &= ~INT_PE1;
GPIO_PORTE_IEV_R |= INT_PE1;
GPIO_PORTE_ICR_R = INT_PE1;
GPIO_PORTE_IM_R |= INT_PE1;
//GPIO_PORTE_PDU_R|= INT_PE1;
NVIC_PRI7_R = 0x00A00000;
NVIC_EN0_R = NVIC_EN0_INT30;

EnableInterrupts();
}
//**************INTERRUPTS*************
void GPIOPortE_Handler(void){
if((GPIO_PORTE_DATARd1_R)== 0){
Delay(1000);
GPIO_PORTE_DATAWr1_R |=0x4;

//delay for 14 seconds
//call motor reversal function
//call lcd

}

GPIO_PORTE_ICR_R=INT_PE1;

}

int main()
{
init_INT_GPIO();
while(1)
{
WaitforInterrupt();
}

void Delay(long value)
{
int l;
for(l = 0; l<value; l++);
}

  • Hello Ghulam,

    It is really hard to understand the code without "Syntaxhighlighter". For future reference, please use "Syntaxhighlighter" while posting code. "Syntaxhiglighter" can be invoked by using the icon

    Ghulam Murtaza said:

    There is no output at all on pin 2 PE2. even I checked the PIR output which was one.

    I don't understand the issue here. Is PE2 (on the TM4C123G device) supposed to be an input or an output? If PE2 is connected to the output of PIR then it should be configured as input.

    Ghulam Murtaza said:

    Also I am facing trouble connecting DC motor of 5V with it. I assigned the output to logic one but the motor didn't turn on.

    Without knowing much about the motor being used, I think you will need additional circuitry (on the lines of L293D) to drive a DC motor.

    Thanks,

    Sai

  • Some (perhaps many) here have noted that poster's use of DRM rather than LONG, "Tried, True, Tested" API makes little sense.

    DRM surely s l o w s your response (and that of other "helpers") due to the necessity to, "Page near continuously thru the MCU manual."

    May we note that if ALL posters employed DRM - forum response would stall - can that be (at all) good? Perhaps each DRM-based poster should be so advised...
  • You're trying to run a motor directly from the micro's pin? That would be an exceedingly optimistic approach.

    Robert
  • Guys Sorry If any of you has problem regarding understanding the problem I have connected PIR out to the PE1(configured as input) and an LED on PE2(configures as output). Please check the code for the bug due to which I am not getting output on PE2 :-(
  • Ghulam Murtaza said:
    Sorry If any of you has problem regarding understanding the problem

    Might it be that (beyond) any of us - ALL of us - have a problem!

    Here are a few:

    • your code is 90%+ DRM - which greatly slows AND complicates our review.   Vendor supplies a powerful API - you've not used that.
    • you first speak of driving a motor - now (only) an Led is mentioned!   While the MCU can drive an Led - unless the motor is puny - you cannot directly drive it.
    • cannot you test your code - save your helpers the time/effort of checking everything?   Surely your code works over some range - does it not?  By your identifying, "When, Where & How" your code fails - you save your helpers great time & energy - do you not?

    You'll help ALL of us via your accepting & following this listing...

  • If I had gimp installed I would edit it to "not the DRM again" but i'm not even sure in it works on windows.



    You want to use DRM okay. At least comment it! How do you even know what's in there? I would get hungry in the mid of making it, go get food and when I came back I would look to it and be scared of it.
    Trust me on this advice - comment the code. You could probably find the problem yourself if you did and most likely faster! And of course even if most of people help don't like DRM, it would give a bigger change of help.

    I'm not just like criticizing you "you did it all wrong" - just saying how I would try to help you and how you can get much more help from users (just adding a bit if you want to insist on register programming, cb1 summed it up better)




  • Same question as cb1, what happened to the motor?

    Robert

    Same recommendations too.
  • Robert & Luis,

    Recall - our DRM favoring poster asks only those (few) "ANY who had problems."

    We should, "Get out of the way - and let ALL those w/out problems" respond to this poster...   (I'd not hold my breath...)