• AVR Freaks

Hot!PIC32MX795F512L HARMONY USART

Author
nibos01
New Member
  • Total Posts : 11
  • Reward points : 0
  • Joined: 2008/10/13 09:30:15
  • Location: 0
  • Status: offline
2019/05/29 19:34:29 (permalink)
0

PIC32MX795F512L HARMONY USART

Hello,
 
I am trying to interface my pic32 with a ublox LARA chip using the USART channel. I developed a simple code using harmony and when I download to the MCU and send the initial command I get response from the device but if I keep repeating the command, then I get nothing back. So, only for the first time the command was sent I will receive a confirmation from it.From that point on I don't.
 
Any ideas what could be happening?.
Thanks
The portion of the code that handles the usarts:
USART0 is the connection with device
USART1 is for me to monitor the commands and what I receive back.
while(e!='\0')
            {
              DRV_USART0_WriteByte (e);
              DRV_USART1_WriteByte (e);
                i++;
            }
              DRV_USART0_WriteByte (0x0D);//CR
              DRV_USART0_WriteByte (0x0A);//LF
                          n = 100000000;
            while(n>0) {
                n--;
            }
            // if byte received in USART instance 0 (USART1 in this case)
            while (!DRV_USART0_ReceiverBufferIsEmpty())
            {
                DRV_USART1_WriteByte(DRV_USART0_ReadByte());
            }
           //DRV_USART1_WriteByte (DRV_USART1_ReadByte());
            DRV_USART1_WriteByte (0x0D);//CR
            DRV_USART1_WriteByte (0x0A);//LF
#1

3 Replies Related Threads

    LostInSpace
    Super Member
    • Total Posts : 258
    • Reward points : 0
    • Joined: 2016/03/11 22:47:59
    • Location: 0
    • Status: offline
    Re: PIC32MX795F512L HARMONY USART 2019/06/01 10:05:53 (permalink)
    0
    We all run into these problems. My advice is to: "Divide and conquer", that is break the problem up into smaller problems.
     
    Start by just being able to send and receive commands with your terminal program. When that is working, then move up in complexity of the program.
     
    By doing this you are always starting from a known working step beforehand and any possible problems are confined to the simple step that you are adding at the moment.
     
    Hope this helps.
    #2
    Gabriel Kapellmann
    New Member
    • Total Posts : 1
    • Reward points : 0
    • Joined: 2015/02/02 06:24:10
    • Location: 0
    • Status: offline
    Re: PIC32MX795F512L HARMONY USART 2019/06/02 11:48:51 (permalink)
    0
    Hello nibos01, 
     
    I am having some issue with that same MCU, similar to yours. I use the USART with an interrupt thought, to send and receive. I like it more this way because in the case of your code it is just waiting for the USART to finish, unless this is not a problem for you.

    I am using Harmony also, I have been able to send and receive if done separately, but for some reason, the only interrupt that is getting fired is the "Transmit" one... not the receive one. It sounds somehow similar to your problem though.
     
    My code that handles the data is:
     
    void __ISR(_UART_1_VECTOR, ipl1AUTO) _IntHandlerDrvUsartInstance0(void){
        if (SYS_INT_SourceStatusGet(INT_SOURCE_USART_1_TRANSMIT)){ 
            DRV_USART_TasksTransmit(sysObj.drvUsart0);
            if(!(DRV_USART_TRANSFER_STATUS_TRANSMIT_FULL & DRV_USART0_TransferStatus()) ){
                appData.tx_byte++;
                if(*appData.tx_byte){
                    DRV_USART0_WriteByte(*appData.tx_byte); 
                }
            }
            BSP_LED_1On();
        }else if (SYS_INT_SourceStatusGet(INT_SOURCE_USART_1_RECEIVE)) {
            DRV_USART_TasksReceive(sysObj.drvUsart0);
            if (!DRV_USART0_ReceiverBufferIsEmpty()){
                appData.rx_byte = DRV_USART0_ReadByte(); // read received byte
                GenUseToggle();
            }
            BSP_LED_2On();
        }else if (SYS_INT_SourceStatusGet(INT_SOURCE_USART_1_ERROR)){
            DRV_USART_TasksError(sysObj.drvUsart0);
            BSP_LED_3On();
        }

    }
     
    Have you tried with interrupts maybe? What I have discovered with this code is that if the MCu is not sending anything, and it receives, it gets stuck... like if it gets trapped in the interrupt, but with transmit, there is no problem!

    Could it be your same situation?
    #3
    nibos01
    New Member
    • Total Posts : 11
    • Reward points : 0
    • Joined: 2008/10/13 09:30:15
    • Location: 0
    • Status: offline
    Re: PIC32MX795F512L HARMONY USART 2019/07/10 10:36:57 (permalink)
    4 (1)
    Guys,
     
    Thanks I was able to establish comms. I had to reconfigure the LTE module because it was different than the MCU. Once I did that I was abel to send and receive commands.
     
    Thanks for the support
    #4
    Jump to:
    © 2019 APG vNext Commercial Version 4.5