Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to recognize interupt handler roots on register level of efr32fg14

Status
Not open for further replies.
Hi,
The program keeps sending the old value over and over(with small delay) till it gets a new command.
In reality when i sent a command letters it sent back nothing.
This is what you told the microcontroller to do.
In main() you send the buffer, then delay, then send the buffer, then delay then send the buffer .... again and again...
you don´t wait until new data is recieved....

****
I´d use a "received_flag". decalred as global UNIT8
In the receive ISR you set the flag = true

in main() you write
* If received_flag then --> send buffer, received_flag=flase

as long as there is no byte received the flag is FALS, no data is transmitted
when a byte is received, that flag is TRUE. The IF recognizes it, sends the buffer, clears the flag to omit the buffer to be sent again and again.

Klaus
--- Updated ---

added:
but usually you want the ISR to be as short as possible (in the meaning of processing time).
Thus the "switch (buffer)" should be within the "IF" in main() loop.

Klaus
 

Hello Klaus, on the first step where I need to set "receive ISR" as true.from page 22 from the maual shown bellow,in the Set-enable register cant see the RECIEVE ISR in the description.
in simplisity studio we have this line for setting values in the ISER register.
Code:
  NVIC->ISER[(((uint32_t)IRQn) >> 5UL)] = (uint32_t)(1UL << (((uint32_t)IRQn) & 0x1FUL));
Where can i see the RECIEVE ISR in this register?
Thanks.

1603568371148.png
 

Hello Klaus,I have tried to implement your advice as shown bellow and its suppose to send tx_buffer always till its replaced by tx_buffer_new.
I have impelemented the received_flag advice as shown bellow,I have checked the pin connection acording to the datasheet page 157 location2 rx portA pin3(P2) ,tx port A pin2(P0) as shown in the photo bellow.
still its not sending anything.
Where did i go wrong?
Thanks.

Code:
#include "em_device.h"
#include "em_cmu.h"
#include "em_gpio.h"
#include "em_usart.h"
#include "em_chip.h"
#include <stdint.h>
#include <stdbool.h>
#include "em_emu.h"
#include "bsp.h"
#include "bsp_trace.h"


uint8_t received_flag=0;//
// Receive data buffer
uint8_t buffer;
uint8_t tx_buffer=0x6F;
uint8_t tx_buffer_new=0x06;


void USART0_RX_IRQHandler(void)
{
    received_flag=1;
  // Get the character just received
  buffer = USART0->RXDATA;

  switch (buffer)
        {
        case 'a':

            tx_buffer_new=0x0F;
          break;

        case 'b':
            tx_buffer_new=0x2F;
        break;

        case 'c':
                    tx_buffer_new=0x4F;
         break;

        default:

        break;

        }//end switch
  // Clear the requesting interrupt before exiting the handler
  USART_IntClear(USART0, USART_IF_RXDATAV);
}



int main(void)
{
  uint32_t i;

  // Chip errata
  CHIP_Init();
  CMU_ClockEnable(cmuClock_GPIO, true);
  CMU_ClockEnable(cmuClock_USART0, true);


  //EFR32fg14 LOC2 page 157 data sheet TX P0
  GPIO_PinModeSet(gpioPortA,2, gpioModePushPull, 1);

//EFR32fg14 LOC2 page 157 data sheet RX P2
  GPIO_PinModeSet(gpioPortA,3, gpioModeInput, 0);

  GPIO_PinModeSet(gpioPortA, 5, gpioModePushPull, 1);


  // Default asynchronous initializer (115.2 Kbps, 8N1, no flow control)
  USART_InitAsync_TypeDef init = USART_INITASYNC_DEFAULT;

  // Configure and enable USART0
  USART_InitAsync(USART0, &init);
  //datasheet page 157 location2  rx portA pin3(P2) ,tx port A pin2(P0)
  USART0->ROUTELOC0 = USART_ROUTELOC0_RXLOC_LOC2 | USART_ROUTELOC0_TXLOC_LOC2;
  USART0->ROUTEPEN |= USART_ROUTEPEN_TXPEN | USART_ROUTEPEN_RXPEN;


  // Enable NVIC USART sources
  NVIC_ClearPendingIRQ(USART0_RX_IRQn);
  NVIC_EnableIRQ(USART0_RX_IRQn);
  NVIC_ClearPendingIRQ(USART0_TX_IRQn);
  NVIC_EnableIRQ(USART0_TX_IRQn);



  while (1)
  {

      if (received_flag==1)
      {
          USART_Tx(USART0,tx_buffer_new);
          USART_Tx(USART1,'\n');
          tx_buffer=tx_buffer_new;
          received_flag=0;
      }
      else
      {
          USART_Tx(USART0,tx_buffer);
                    USART_Tx(USART1,'\n');
      }
      for(i=0;i<115;i++)
      {
            GPIO_PinOutSet(gpioPortA,5);
            GPIO_PinOutClear(gpioPortA,5);
       }

    // Enable receive data valid interrupt
    USART_IntEnable(USART0, USART_IEN_RXDATAV);







  }
}

1603627043810.png


1603627111776.png
 
Last edited:

***********************************************
UPDATE:
found some small error i user a line with usart 1 i fixed it .
--- Updated ---

Hello Klauss, In my original wrong code I have updated the tx_buffer inside the handler.
But it didnt update the tx_buffer inside the endless while(1) loop.
Only after we did the flag method you suggested, it did updated the tx_buffer.
Why my method didnt work?
the while(1) should not have prevented the update of sending the new updated tx_buffer.

it should have update the tx_buffer in the while(1) and it should have sent a new value.

You suggested to move the CASE switch code from the RX handle function to the main() to do the code more efficient.
But its the same issue as before .how do iknow that the tx_buffer wont hold the old value for case switch?

Thanks.
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top