debug print on the console (video tutorial example)

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
MaH_4035971
Level 2
Level 2
10 replies posted 5 replies posted 5 questions asked

Hello,

I was following the instructions of the "Welcome to ModusToolbox" videos series where Alan explains how to create a UART serial com.

1) In the video #2 configuring PSoC Devices @4:17 Alan configures the TX pin by clicking on the link button. The pin drive mode is automatically set to Strong Drive, Input buffer off however in my case it defaults to Open drain, Drive low, input buffer on.

> I am using the CY8CPROTO-063-BLE kit and not CY8CKIT-062-WiFi-BT kit as in the video, is that why ? What is the correct configuration for the UART TX pin ?

2) In the video #4 Program & Debug @1:38 Alan includes the stdio.h file however in the previous video ( #3 Selecting Middleware) he's been working on stdio_user.h

> Which is the correct include ?

3) Surprisingly I have tried all combination above (TX pin to strong drive/open drain and include stdio.h/stdio_user.h) and I got no error message during the build but I couldn't see anything on the console. I left the blinking LED code so I know that the program is running.

I am using Mac OS 10.14.1 but I don't think the console is the issue because it worked fine when I used fw-loader to upgrade KitProg2 to KitProg3.

> What am I missing ?

Thanks

0 Likes
1 Solution

I ran your project as is and it works perfectly fine for me as seen below:

modus3.PNG

Are you setting the right parameters in the Serial Terminal? Here are the right settings, change the COM port accordingly.

modus4.PNG

Regards,

Dheeraj

View solution in original post

11 Replies
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

Yes, ModusToolbox should automatically assign the drive modes when you provide the TX and the RX pin. However, if it is unable to do so you can do it manually in two ways:

First method: In the Device Configurator, you will see a Notice List window which lists all the errors. If you don't see it, go to View > Notice List. So in your case, you should be seeing the following:

uart1_marked.png

You can click on the drop-down near the spanner logo and Modus will automatically fix the errors for you by assigning the right drive mode.

Second method: If you know the drive modes, you can assign them manually for the TX and RX pin in the Pins tab as shown below:

uart2_marked.png

The correct drive modes are:

  • TX Pin: Strong drive input buffer off
  • RX Pin: Digital High-Z Input buffer on

The file retarget.c (created when you enable middleware for retarget I/O) defines functions that replace weakly linked I/O functions in the standard library (i.e. _write() and _read()). The functions in retarget.c in turn call the STDIO_PutChar() and STDIO_GetChar() implemented in stdio_user.c.

So you need to include "stdio.h" itself which is the standard library and all the files stdio_user.c/h are just making some modifications to how the write and read is done, they in turn use the stdio library itself.

About the last question, have you provided the right SCB inside "stdio_user.h" as shown below:

uart_scb.PNG

You could also give the alias name you have used for UART in the configurator after including "cycfg.h" inside "stdio_user.h"

Regards,

Dheeraj

Dear Dheeraj,

Thanks you for your quick reply.

I selected the right drive mode for TX and included stdio.h I also made sure that stdio_user.h contained the right define for the UART (actually I renamed in Bridge_UART in the peripheral tab of the device configurator, like Alan did in the video) so I have :

#define IO_STDOUT_ENABLE

#define IO_STDIN_ENABLE

#define IO_STDOUT_UART      Bridge_UART_HW

#define IO_STDIN_UART       Bridge_UART_HW

I still can't see anything on any of the consoles (modusToolbox console or Mac OS console). Then I deleted the name and used SCB5 instead in the stdio_user.h as shown on your screenshot. I had to modify main.c accordingly:

    /* Set up UART */

    Cy_SCB_UART_Init( SCB5, &scb_5_config, &uart_context );

    Cy_SCB_UART_Enable( SCB5 );

Still nothing shows up on the console but there is no error or problem and the led is blinking (I removed the breakpoint)... it's a bit frustrating not to be able to identify the problem...

Cheers !

Edit: In the variable window I can see that x is being updated in the loop. I guess the problem must come from the console. Where is the printf command supposed to be showing up on a Mac ? The system console does not show anything, is there another one ? Alan mentions "something"term and Putty, but Mac OS apparently has built-in SSH capabilities (How to SSH on Mac with the Native SSH Client ) however I have never used it... Following the instructions from osxdaily.com I enabled SSH and got confirmation from the console:

Remote Login: On

But still nothing when I run my PSoC-UART script...

Is is possible to configure the UART service so that it prints inside ModusToolbox console ?

#include "cy_device_headers.h"

#include "cycfg.h"

#include "stdio.h"

int main(void)

{

    /* Set up the device based on configurator selections */

    init_cycfg_all();

    __enable_irq();

    Cy_SCB_UART_Init(Bridge_UART_HW, &Bridge_UART_config, NULL);

    Cy_SCB_UART_Enable(Bridge_UART_HW);

   

    /* Check if this line is being printed */

    Cy_SCB_UART_PutString(Bridge_UART_HW, "Uart init");

    printf("Hello World\r\n");

    for(;;)

    {

    Cy_GPIO_Inv(RED_LED_PORT, RED_LED_NUM);

    Cy_SysLib_Delay(500);

    }

}

This is what my main looks like. Please check if PutString() prints anything to the console or not. If it works, then even the printf should work. Make sure you add the "\r\n" in the printf.

Regards,

Dheeraj

lock attach
Attachments are accessible only for community members.

nope... still nothing.

here is the archive in case I missed something. I have #include "cy_pdl.h" instead of #include "cy_device_headers.h"

0 Likes

I ran your project as is and it works perfectly fine for me as seen below:

modus3.PNG

Are you setting the right parameters in the Serial Terminal? Here are the right settings, change the COM port accordingly.

modus4.PNG

Regards,

Dheeraj

I can't find the terminal window. I followed the instructions here Using Serial Terminal and COM Support in Eclipse Oxygen and Neon | MCU on Eclipse but there is no terminal anywhere. I looked in Window>Show view>other and all the subfolders...

Is the Mac version different ?

screenshot.jpg

0 Likes

It will work with any Serial Terminal software like Tera Term, Putty etc.. However, if you want to know more about enabling the terminal plugin for eclipse, you can refer to this thread:

Regards,
Dheeraj

0 Likes

For a serial terminal, I usually do use PuTTy outside of ModusToolbox. But, I am able to use a terminal inside of Eclipse after I followed the correct answer here Eclipse plugins in ModusToolbox?

After doing that, I don't see "Launch a terminal" or anything like that in Eclipse, though I am sure it is somewhere. There are so many menus and menu entries in Eclipse. What I do see is this in my toolbar (this is Windows).   You can show the Toolbar from Windows->Appearance.

pastedImage_1.png

I should note that I have installed the TM plugin. Maybe it doesn't put anything in the menus, but only in the toolbar.

Alright slowly I'm getting there. I installed the following plug-ins:

Screenshot 2019-04-12 at 18.29.12.png

which gave me access to the console inside ModusToolbox but it's still empty:

Screenshot 2019-04-12 at 18.34.23.png

I guess what I'm missing is the "launch terminal window" where the serial port settings are defined as Dheeraj posted:

modus4.PNG

Where is it ? do I need another plug-in ?

Thanks guys !

0 Likes

Clicking on the "Open a terminal" icon brings up the Launch Terminal window where you select the type of terminal and add the required settings.

modus5_makred.png

Regards,

Dheeraj

Yeah everything is working fine now, thanks guys !

Just to wrap up in case anybody else is in the same situation: To open a serial terminal window,

1) Go to Help>Install New Software

1.png

2) If not present in the drop-down list, add the following repository: http://download.eclipse.org/releases/oxygen (I named it "oxygen")

2.png

3) Work with "oxygen" repository and select TM Terminal and TM Terminal Serial Connector Extensions in the Linux Tools subfolder. Install and restart ModusToolbox

Note: Others have advised a slightly different method using Eclipse Marketplace Client ( see Eclipse plugins in ModusToolbox? )

3.png

4) Go to Window>Show View>Other and select Terminal in the Terminal subfolder

4.jpg

5) The serial terminal window is now available (serial communication e.g. baud rate, port, etc can be configured by clicking on the small "screen" icon, see Dheeraj's and Matt's post above)

Screenshot 2019-04-14 at 19.31.51.png

Thanks !