• AVR Freaks

Helpful ReplyHot!UART TX not transmitting data (dsPIC33EV32GM104) regarding

Page: 12 > Showing page 1 of 2
Author
vijayakumar.sargunam
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2012/10/12 22:59:47
  • Location: 0
  • Status: offline
2021/01/28 03:45:49 (permalink)
0

UART TX not transmitting data (dsPIC33EV32GM104) regarding

Hi,
 
        I created a UART/ADC project using MCC plugin. I successfully covert the sensor data to digital data using ADC module ad i tried to transmit the ADC data through UART to PC. While debugging it seems that my transmit buffer is always empty (TMRT = 0)Even though i send the value to U1TXREG. I tried many times and its unsuccessful. with this i attached the debug image and part of the code.
while(!ADC1_IsConversionComplete(channel_AN54));
conversion = ADC1_ConversionResultGet(channel_AN54);
// if(UART1_IsTxReady == true)
// {
// while(!UART1_IsTxDone);
UART1_Write(conversion);
UART1_Write('a');
// }

 
post edited by vijayakumar.sargunam - 2021/01/29 03:26:05

Attached Image(s)

#1
J_D
New Member
  • Total Posts : 14
  • Reward points : 0
  • Joined: 2019/02/26 23:28:25
  • Location: 0
  • Status: offline
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/01/28 04:40:06 (permalink)
0
Hi Vijay,

Could you please attach main.c, pin_manager.c and uart.c files to very the configuration and API calls
 
Regards,
JD
#2
Aussie Susan
Super Member
  • Total Posts : 3827
  • Reward points : 0
  • Joined: 2008/08/18 22:20:40
  • Location: Melbourne, Australia
  • Status: offline
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/01/28 18:38:47 (permalink)
0
How are you determining this?
When you are using the debugger, remember that the hardware cannot tell the difference between register accesses by your program and the debugging kernel that is loaded along with your code into the MCU. Therefore registers that are controlled by hardware and are cleared on read access can give you misleading information.
Also are you getting any signal on the Tx pin (as seen on an oscilloscope)?
Susan
#3
ric
Super Member
  • Total Posts : 29870
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/01/28 18:49:12 (permalink) ☄ Helpfulby vijayakumar.sargunam 2021/02/01 02:52:53
0
vijayakumar.sargunam
... While debugging it seems that my transmit buffer is always empty (TMRT = 0)



Actually, "empty" is when TRMT = 1, but that is what your watch window is showing.
You can't see what the TRMT bit is doing while single stepping your code. That bit will only be cleared for a fraction of a second as the character is being sent, then will return to 1.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#4
vijayakumar.sargunam
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2012/10/12 22:59:47
  • Location: 0
  • Status: offline
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/01/29 03:19:16 (permalink)
0
Thanks for everyone who replied,
 
             I changed the main.c file with following code. I simply transmit the character 'a' in a loop. I tested the transmit pin with oscilloscope and i attached the image in this tag. I got some waveform in the oscilloscope the transmit LED is continuously glows without flickering. And iam not getting the character 'a' in the terminal. i set my baud rate = 9600, Data Bits = 8; Parity = None; Stop Bits = 1;  Shall i give delay before transmitting the next character?. And also i attached the main.c, pin_manager.c and uart1.c file for reference.
             
while(1)
{
while (U1STAbits.UTXBF);
U1TXREG = 'a';
while(!U1STAbits.TRMT);
}
             
#5
ric
Super Member
  • Total Posts : 29870
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/01/29 03:47:50 (permalink)
0
You don't need the second while()
Pleae do NOT edit the first post once you start getting answers.
Click the "(Open Full Version)" lkink above the edit window to get all the controls to attach images to a new post.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#6
ric
Super Member
  • Total Posts : 29870
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/01/29 03:57:35 (permalink)
0
You are allowing your main() function to exit, which is a big NO NO in an embedded environment.
That is because you commented out the while(1) that is meant to make it stay inside the main() function.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#7
vijayakumar.sargunam
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2012/10/12 22:59:47
  • Location: 0
  • Status: offline
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/01/29 04:44:40 (permalink)
0
Hi JD,
 
        I attached the files with the main tag. plz verify
#8
vijayakumar.sargunam
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2012/10/12 22:59:47
  • Location: 0
  • Status: offline
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/01/29 04:48:49 (permalink)
0
Hi susan,
              As you suggested i checked the transmit pin and i got the waveform which is confusing for me. iam transmitting the character 'a' and iam getting this waveform from the transmitting pin which is attached with this post 

Attached Image(s)

#9
ric
Super Member
  • Total Posts : 29870
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/01/29 04:55:54 (permalink)
0
Have you read my second post (from an hour ago) ?

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#10
vijayakumar.sargunam
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2012/10/12 22:59:47
  • Location: 0
  • Status: offline
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/01/29 05:26:54 (permalink)
0
Hi ric,
 
        Thanks for suggesting about full edit. As you suggested I fine tuned my code which is attached below. And the corresponding TX waveform also attached. I am attaching the COM terminal window where i am not getting any characters. 
 
 
 
/**
  Generated main.c file from MPLAB Code Configurator

  @Company
    Microchip Technology Inc.

  @File Name
    main.c

  @Summary
    This is the generated main.c using PIC24 / dsPIC33 / PIC32MM MCUs.

  @Description
    This source file provides main entry point for system initialization and application code development.
    Generation Information :
        Product Revision : PIC24 / dsPIC33 / PIC32MM MCUs - 1.170.0
        Device : dsPIC33EV32GM104
    The generated drivers are tested against the following:
        Compiler : XC16 v1.61
        MPLAB : MPLAB X v5.45
*/

/*
    (c) 2020 Microchip Technology Inc. and its subsidiaries. You may use this
    software and any derivatives exclusively with Microchip products.

    THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
    EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
    WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
    PARTICULAR PURPOSE, OR ITS INTERACTION WITH MICROCHIP PRODUCTS, COMBINATION
    WITH ANY OTHER PRODUCTS, OR USE IN ANY APPLICATION.

    IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
    INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
    WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
    BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE
    FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
    ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
    THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.

    MICROCHIP PROVIDES THIS SOFTWARE CONDITIONALLY UPON YOUR ACCEPTANCE OF THESE
    TERMS.
*/

/**
  Section: Included Files
*/
#include "mcc_generated_files/system.h"
#include "mcc_generated_files/uart1.h"
#include "mcc_generated_files/adc1.h"
#include <stdio.h>
#include <libpic30.h>
//unsigned char temp;
//uint16_t conversion=0;
        
        
int i=0;
/*
                         Main application
 */
//#define LEDS_ON_OFF 0x0001;
//#define LEDS_OFF_ON 0x0000;
#define IC_DELAY 1500000
int main(void)
{
    SYSTEM_Initialize();
    while(1)
    {
        UART1_Write('a');
        printf("Hello\r\n");
        __delay32(IC_DELAY); // delay in instruction cycles
        __delay32(IC_DELAY); // delay in instruction cycles
        __delay32(IC_DELAY); // delay in instruction cycles
        __delay32(IC_DELAY); // delay in instruction cycles
        __delay32(IC_DELAY); // delay in instruction cycles
        __delay32(IC_DELAY); // delay in instruction cycles
        __delay32(IC_DELAY); // delay in instruction cycles
        __delay32(IC_DELAY); // delay in instruction cycles
        __delay32(IC_DELAY); // delay in instruction cycles
        
    }

    return 1;
}
/**
 End of File
*/



Attached Image(s)

#11
du00000001
Just Some Member
  • Total Posts : 4114
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/01/29 06:33:23 (permalink) ☄ Helpfulby vijayakumar.sargunam 2021/02/01 02:53:18
0
vijayakumar.sargunam
Hi susan,
              As you suggested i checked the transmit pin and i got the waveform which is confusing for me. iam transmitting the character 'a' and iam getting this waveform from the transmitting pin which is attached with this post 



Don't know how you managed that, but the trace you're showing must be inverted: the "idle" logic level of UART is "1", while your plot shows a '0' for the idle level.
Beyond that, the trace looks like an 0xE5 - certainly not an 'a' (0x61).But might be you changed your test character without noticing us. Could be an 0x55 with some parity bit set as well - provided the UART is set to transmit only 7 bits.
What you might not be aware of: UART transmission is usually "LSBit first", so the LSBit follows the start bit (reading the trace screen left to right).
 

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#12
Aussie Susan
Super Member
  • Total Posts : 3827
  • Reward points : 0
  • Joined: 2008/08/18 22:20:40
  • Location: Melbourne, Australia
  • Status: offline
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/01/30 23:15:23 (permalink) ☄ Helpfulby vijayakumar.sargunam 2021/02/01 02:53:35
4 (1)
How have you set up the 'printf' output? If you are using UART1 then you will be confusing things badly as that is the same UART you are trying to test.
You keep showing us different main files - this is making helping you very confusing.
For now, initialise UART1 and then use the code:

while(1)
{
    while (U1STAbits.UTXBF);
    U1TXREG = 'a';
}

and that will give you just a stream of 'a' characters to look at.
Susan
 
#13
vijayakumar.sargunam
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2012/10/12 22:59:47
  • Location: 0
  • Status: offline
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/02/01 02:49:30 (permalink)
0
Hi susan
       Iam transmitting the characters as per your suggestion. Iam transmitting different characters apart from 'a'. Iam transmitting characters like 'J' and hex values like 0xAA and 0xEE and corresponding waveforms are attached for your perusal. It is sending start bit (low bit) followed by LSB low to high bits and followed by MSB low to high bits. But iam not getting any characters in my console even though my baud rate settings are correct.
post edited by vijayakumar.sargunam - 2021/02/01 02:55:21

Attached Image(s)

#14
ric
Super Member
  • Total Posts : 29870
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/02/01 03:00:43 (permalink)
0
Now you are showing some good looking TTL wave forms.
How does that signal get into your PC?
If you're using a USB to serial adaptor with a DE9 connector, it will be expecting RS232 voltage levels.
Do you have something similar to a MAX232 buffer to do that?
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#15
vijayakumar.sargunam
Starting Member
  • Total Posts : 33
  • Reward points : 0
  • Joined: 2012/10/12 22:59:47
  • Location: 0
  • Status: offline
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/02/01 03:41:12 (permalink)
0
Hi ric,
 
yes i am using a MAX232 level convertor board and a prolific Serial to USB adapter with DB9 connector on one end. I am using a docklight software to view the serial data in PC.I attached the pic of my experimental setup and COM terminal.

Attached Image(s)

#16
ric
Super Member
  • Total Posts : 29870
  • Reward points : 0
  • Joined: 2003/11/07 12:41:26
  • Location: Australia, Melbourne
  • Status: online
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/02/01 04:04:10 (permalink)
0
Are you sure you have wired it correctly?
Your photo is too small for us to see.
 

I also post at: PicForum
Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
NEW USERS: Posting images, links and code - workaround for restrictions.
To get a useful answer, always state which PIC you are using!
#17
oliverb
Super Member
  • Total Posts : 403
  • Reward points : 0
  • Joined: 2009/02/16 13:12:38
  • Location: 0
  • Status: offline
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/02/01 05:08:36 (permalink)
0
FWIW I used the following loop to create a simple "echo" demo on a dsPIC33CH. Not a lot of point posting the whole project as it uses both cores.
 
    while (1)
    {
        // Add your application code
        if (!UART1_IsRxReady())
        {
            UART1_Write(UART1_Read());
        }
    }

#18
du00000001
Just Some Member
  • Total Posts : 4114
  • Reward points : 0
  • Joined: 2016/05/03 13:52:42
  • Location: Germany
  • Status: offline
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/02/01 06:45:25 (permalink)
5 (1)
vijayakumar.sargunam
Hi ric,
 
yes i am using a MAX232 level convertor board and a prolific Serial to USB adapter with DB9 connector on one end. I am using a docklight software to view the serial data in PC.I attached the pic of my experimental setup and COM terminal.



About time to check (scope!) the signal on the RS-232 side !

PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
#19
Jerry Messina
Super Member
  • Total Posts : 666
  • Reward points : 0
  • Joined: 2003/11/07 12:35:12
  • Status: offline
Re: UART TX not transmitting data (dsPIC33EV32GM104) regarding 2021/02/01 07:33:32 (permalink)
0
I have a hard time reading those scope photos, but it almost looks to me like the single bit time is on the order of 20us, which would put the baud rate at 50K.
 
If I'm blind, just ignore this.
 
#20
Page: 12 > Showing page 1 of 2
Jump to:
© 2021 APG vNext Commercial Version 4.5