Community
cancel
Showing results for 
Search instead for 
Did you mean: 
mo_bri
New Contributor I
1,156 Views

How do I see the output from the QM_PRINTF macro in the examples

Hi,

I want to see the output from the example for the compass settings, the code uses a macro to (I presume) output to a serial monitor window.

Connection-wise I have a standard micro usb connection to the D2000 (do I need a JTAG cable ???). I want the output of the QM_PRINTF macro to be visible in eclipse (ISS IDE). My code when building warns me the

Description Resource Path Location Type

Unused static function 'degrees_to_direction' main.c /Magnetometer_Compass line 49 Code Analysis Problem

This is because the only code to use this function is this

QM_PRINTF("mag x %d y %d z %d deg %d direction %s\n", mag.x, mag.y,

mag.z, deg, degrees_to_direction(deg));

When I expand the QM_PRINTF (using F3) macro I see

# if (PRINTF_ENABLE)

int pico_printf(const char *format, ...);

# define QM_PRINTF(...) pico_printf(__VA_ARGS__)

# else

# define QM_PRINTF(...)

# endif /* PRINTF_ENABLE */

So my pre-prcoessor directives mean that I am defining # define QM_PRINTF(...), so this means do nothing, and therefore the code to call the above function is not doing anything hence the warning.

So my question...

How do I turn on the QM_PRINTF to output in the Serial Monitor window in the Intel Software Studio IDE ?

0 Kudos
8 Replies
idata
Community Manager
36 Views

Hi Marcuso,

Can you send me the screenshot of the warning that you are getting? I ran the code without problems and it gave me the results on the serial port window of ISSM.

I will be waiting for your reply, have a nice weekend.

Regards,

-Leonardo

mo_bri
New Contributor I
36 Views

The steps I take (using ISS build Update 1 - no updates available - thie is the latest :Build: issm_q2_2016_32_2016-07-26-0-g9e73b2ad5b)

1. Create project - defaults - use magnet as the example

2. Here is the code

/*

* Copyright (c) 2016, Intel Corporation

* All rights reserved.

*

* Redistribution and use in source and binary forms, with or without

* modification, are permitted provided that the following conditions are met:

*

* 1. Redistributions of source code must retain the above copyright notice,

* this list of conditions and the following disclaimer.

* 2. Redistributions in binary form must reproduce the above copyright notice,

* this list of conditions and the following disclaimer in the documentation

* and/or other materials provided with the distribution.

* 3. Neither the name of the Intel Corporation nor the names of its

* contributors may be used to endorse or promote products derived from this

* software without specific prior written permission.

*

* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"

* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE

* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

* ARE DISCLAIMED. IN NO EVENT SHALL THE INTEL CORPORATION OR CONTRIBUTORS BE

* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR

* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF

* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS

* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN

* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)

* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE

* POSSIBILITY OF SUCH DAMAGE.

*/

# include

# include

# include "qm_interrupt.h"

# include "qm_rtc.h"

# include "qm_uart.h"

# include "qm_isr.h"

# include "bmx1xx/bmx1xx.h"

# define ALARM (QM_RTC_ALARM_SECOND >> 3)

# define M_PI 3.14159265358979323846

# if (QUARK_D2000)

# define SAMPLING_DURATION 500

static uint16_t cb_count = 0;

static const char *degrees_to_direction(unsigned int deg)

{

if (deg >= 360) {

deg %= 360;

}

if (deg >= 338 || deg < 23) {

return "N";

} else if (deg < 68) {

return "NE";

} else if (deg < 113) {

return "E";

} else if (deg < 158) {

return "SE";

} else if (deg < 203) {

return "S";

} else if (deg < 248) {

return "SW";

} else if (deg < 293) {

return "W";

} else {

return "NW";

}

}

static void print_magneto_callback(void *data)

{

bmx1xx_mag_t mag = {0};

double heading;

int deg;

bmx1xx_read_mag(&mag);

heading = atan2(mag.y, mag.x);

if (heading < 0) {

heading += 2 * M_PI;

}

deg = (int)(heading * 180 / M_PI);

QM_PRINTF("mag x %d y %d z %d deg %d direction %s\n", mag.x, mag.y,

mag.z, deg, degrees_to_direction(deg));

if (cb_count < SAMPLING_DURATION) {

qm_rtc_set_alarm(QM_RTC_0, (QM_RTC[QM_RTC_0].rtc_ccvr + ALARM));

cb_count++;

} else {

QM_PUTS("Finished: Magnetometer example app\n");

}

}

# endif

int main(void)

{

# if (QUARK_D2000)

bmx1xx_setup_config_t cfg;

qm_rtc_config_t rtc;

# endif

int rc = 0;

QM_PUTS("Starting: Magnetometer example app\n");

# if (QUARK_D2000)

rtc.init_val = 0;

rtc.alarm_en = true;

rtc.alarm_val = ALARM;

rtc.callback = print_magneto_callback;

rtc.callback_data = NULL;

qm_irq_request(QM_IRQ_RTC_0, qm_rtc_isr_0);

clk_periph_enable(CLK_PERIPH_RTC_REGISTER | CLK_PERIPH_CLK);

cfg.pos = BMC150_J14_POS_0;

rc = bmx1xx_init(cfg);

if (rc != 0) {

return rc;

}

rc = bmx1xx_mag_set_power(BMX1XX_MAG_POWER_ACTIVE);

if (rc != 0) {

return rc;

}

rc = bmx1xx_mag_set_preset(BMX1XX_MAG_PRESET_HIGH_ACCURACY);

if (rc != 0) {

return rc;

}

qm_rtc_set_config(QM_RTC_0, &rtc);

# else

QM_PUTS("Mag sensor app not available for Quark SE dev board\n");

QM_PUTS("Finished: Magnetometer example app\n");

# endif

return rc;

}

I haven't touched any of the code. I then build with automatic on, then turn off automatic and use release, then use debug. All of these options give me the same warning (see picture attached). I can not believe you don't have this problem on a windows build, as the line of code with the printf macro will not be compiled, due to the macro is not defined. That means the func is not used in the com;ilation and therefore the warning appears. This is a preprocessor macro !

BTW This is WINDOWS 10 build, not linux. Therefore I think you have the QM_PRINTF macro defined. In windows it id not defined by default, and therefore the func does not get used...

QM_PRINTF("mag x %d y %d z %d deg %d direction %s\n", mag.x, mag.y, mag.z, deg, degrees_to_direction(deg));

If QM_PRINTF was defined then degrees_to_direction would be called, and therefore no warning.

So let me know how you don't get this build, select the QM_PRINTF macro and hit F3 (declaration in eclispe), make sure you dont get taken to (...).

Marcus

dhenr1
Beginner
36 Views

Remember, the D2000 may look like an Arduino but its actually a lot different.

The Arduino combines the Serial UART with the flash loader on the USB cable plugged into the USB micro socket. However thay dont work together. You can upload the sketch to the board then switch to Serial I/O. There's no debugger.

THe D2000 USB cable is a fully fledged JTAG debugger, QM_PRINTF output goes to the UART_0 pins 0 & 1. You have to connect an FTDI cable from pins 0/1 to USB on your PC and open up a Serial Monitor e.g. Realterm. QMSI also has a built-in Serial Monitor you could use instead.

Pity Intel didn't copy the TI Launchpad. There the USB cable can simultaneously act as a Serial cable and JTAG so you can debug and do I/O at the same time without extra hardware.

mo_bri
New Contributor I
36 Views

Hi ngaman,

Thanks for taking the time to explain things to me, it's difficult finding anything out about the d2000 ! So I want to see the UART output, I have 2 cables that might allow me to capture it and display the o/p on the pc in QMSI Realterm in eclipse (ISS IDE).

The first cable, its just a USB cable with a 5 female pin header on it, can I just connect two of these pins to tx and rx on the d2000 (pins 0 and 1) ? And obviously plug the USB side into my PC ? The pins are 1 black, 2 red, 3 black, 4 green, 5 white. I think this came from a HDMI board for a TFT screen.

OR

The second cable I found is a normal micro USB cable but I plugged it into a FTDI board I found. This board has a FTDI 0613A FT245RL. Ive plugged the usb cable into the usb port, and on the other side is a 10 male pin square connector - can I plug pins 0 and 1 on the d2000 to some of these pins ? This FTDI board was for debugging a eCOG chip made by Cyan Technology in the UK

Also if I want to debug an Arduino can you recommend a jtag cable for that ? Thanks I am really !!

Marcus

idata
Community Manager
36 Views

Hi Marcus,

I found the warning that you were talking about, and I has it too, but I think that it isn't relevant in the example code.

About the FTDI cable, I personally recommend you to use a standard FTDI cable (6 pins), take a look at these images:

At the second image you have to use the following pins:

-GND (Black) to D200 GND.

-TXD(Orange) to Pin 0 D2000.

-RXD(Yellow) to Pin 1 D2000.

Once you connect the cable, you have to install the driver: http://www.ftdichip.com/Drivers/D2XX.htm.

If you do this you will be able to see the results on the serial monitor of your IDE.

Regarding the Arduino JTAG cable, I think that you should contact them for a better support: https://www.arduino.cc/

I hope you find this information useful.

Regards,

-Leonardo

idata
Community Manager
36 Views

Hi Marcus,

Was the information helpful? Did you get the FTDI cable?

Let us know if you still have issues.

Regards,

-Leonardo

mo_bri
New Contributor I
36 Views

I've ordered a USB plugin dongle for $2.46. That's the good point, the bad point is it takes 4 weeks to get here, from China to Canada !

It's a FT232RL FTDI Serials Adapter Module Mini Port f. Arduino USB

So, I'm still waiting !

idata
Community Manager
36 Views

Hi Marcus,

That's great!

Let us know when you tested it.

Regards,

-Leonardo

Reply