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.

Need help with codings for creating a program to receive signals.

Other Parts Discussed in Thread: TM4C123GH6PM

Hey guys,
currently i am working on creating a program that can allow my first TIVA board to receive pulses transmitted from my 2nd TIVA board, and after that to use the first TIVA board to send out 1 pulse to the 2nd TIVA board. I was wondering if you guys could help/advise me with what codes i should be using. Thanks alot for helping. I really appreciate it a lot!!

  • Hello Desmond,

    What kind of pulses? Why use pulse when UART, I2C and SSI can be used to form communication protocol for Point to point connections?

    Regards
    Amit
  • Hello, if i am not wrong, i am sending out digital pulses. I am not very sure myself, sorry for the inconvenience!
  • I am planning to use the timer function to do so.
  • As an example, do u mind explaining what does TIMER_CFG_ONE_SHOT_UP mean, the TI periph guide states (- Full-width one-shot timer that counts up instead of down) However i am still unclear by what it means.
  • Hello Desmond,

    It is still unclear to me the intention of the design. If you want to send pulses from one Tiva board to another and get the other Tiva board to recognize it, then would suggest using the GPIO Interrupt Handler to detect edge rather than Timer

    Regards
    Amit
  • Yes that would work too. Thanks for clearing this up for me :)
    Currently i am trying to send 10 pulses into the TIVA board, and i am configuring rising edges that will trigger the GPIO interrupt.
    Meaning that in the interrupt handler, i will use count_state which will keep counting until after the pulses are sent out, before sending out the 1 pulse. However, how do i know how many count_states are required ?
  • Hello Desmond

    Yes, that is correct. The count_state must be compared against the condition for which the one pulse needs to be sent out. At the same time you would need to reset the count_state variable

    Regards
    Amit
  • I am trying to send out the 1 pulse after the 10 pulses from the first TIVA board is sent out. However, how do i know how long the count_state needs to be
  • Hello Desmond,

    Why do you want to count the length of the pulse when the communication is based on the count of pulses!!!

    Regards
    Amit
  • This is the program i wrote to receive the pulses. The other program has been set to transmit 10 pulses using Port E pin 0.
    However, nothing seems to be happening.

    #include <stdint.h>
    #include <stdbool.h>
    #include "inc/hw_memmap.h"
    #include "inc/hw_types.h"
    #include "driverlib/debug.h"
    #include "driverlib/sysctl.h"
    #include "driverlib/adc.h"
    #include "driverlib/gpio.h"
    #include "driverlib/interrupt.h"
    #include "inc/tm4c123gh6pm.h"
    #include "driverlib/timer.h"
    uint32_t Period;

    //////////////////////////////////////////
    #include "driverlib/rom.h"
    #define TARGET_IS_BLIZZARD_RB1// Make the memory of the program smaller/*

    uint32_t FLAG_STATE;
    void PortEIntHandler(void);
    int main(void) {
    //SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); // Enable port F to drive LED
    SysCtlClockSet(SYSCTL_SYSDIV_5|SYSCTL_USE_PLL|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
    Period= (SysCtlClockGet() / 4000); // To get 10KHz
    Period=SysCtlClockGet();
    GPIOIntTypeSet(GPIO_PORTE_BASE, GPIO_PIN_0, GPIO_RISING_EDGE); // Falling edge to detect from high to low
    GPIOIntRegister(GPIO_PORTE_BASE, PortEIntHandler);
    GPIOIntEnable(GPIO_PORTE_BASE, GPIO_INT_PIN_0);
    IntEnable(INT_GPIOE);
    while(1){

    }

    }
    void PortEIntHandler(void){

    FLAG_STATE++;
    if(FLAG_STATE==10){
    GPIOIntClear(GPIO_PORTE_BASE, GPIO_INT_PIN_0);
    GPIOPinWrite(GPIO_PORTE_BASE,GPIO_PIN_3,~GPIOPinRead(GPIO_PORTE_BASE,GPIO_PIN_3));// Toggle output
    // GPIOPinRead(GPIO_PORTE_BASE,GPIO_PIN_0,GPIO_FALLING_EDGE);
    GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_3,0x08); // Turn on green LED
    FLAG_STATE=0;
    }
    else{
    GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_3,0x0); // Turn off green LED

    }
    }
  • Hello Desmond.

    A good attempt at the code. I am happy you took the posts so far to construct the code. The only issue that I seem to have with the code is that GPIO Pin E0 is not configured as input and GPIO Pin F3 is not configured as output.

    Missing API: GPIOPinTypeGPIOInput and GPIOPinTypeGPIOOutput.

    Might I suggest using the TI Pin Mux to generate the configuration.

    Regards
    Amit
  • Do u mind explaining TI pin mux? i have not heard of it.
  • Hello Desmond

    TI Pin Mux Tool is a utility for configuring IO for different peripherals. This reduces the chances of issue in application due to a missing IO configuration.

    e2e.ti.com/.../451208

    Regards
    Amit