pitIsrFlag Sensor Fusion SDK Question

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

pitIsrFlag Sensor Fusion SDK Question

1,274 Views
randyjohnson
Contributor II

I just purchased a K64F-AGM01 assembly. Never used the NXP products before. I'm stuck. I've searched the community for hours and hours for answers. Read every documentation I could find. Still can't seem to find the information that I need to build my project.

I loaded a SDK example for sensor fusion. Ran the example in debugger, but it runs through the cycle once, and since pitIsrFlag doesn't == true on the first pass, the program ends. I get no data from the sensor fusion functions. Am I supposed to write my own program to call the bare metal main function from a loop I create separately?

Labels (1)
8 Replies

833 Views
michaelestanley
NXP Employee
NXP Employee

Randy,

Let me ask, are you trying to single step through the debugger?  If you try that on the

if (true == pitIsrFlag) {

statement, you will go nowhere fast.  

pastedImage_1.png

The reason is that the PIT timer is programmed to "freeze" in debug mode.  From the PIT chapter of the K64 Reference Manual:

pastedImage_2.png

The good news is that you can put a break at the next line after the IF, RUN to that point, then continue single stepping.

Does your board flash green on LED D12 on the K64 when you just power it up outside the debugger?  If so, the app is running fine and this is just a pilot error.

The other thing you should do is startup the sensor fusion toolbox and connect to the board.  That will enable you to see it operating correctly.

Regards,

Mike

0 Kudos

833 Views
randyjohnson
Contributor II

Thanks Mike,

Really appreciate your reply. Yes, everything works when I run Sensor

Fusion Toolbox. I'll try putting a break as you suggest.....Another

question: Is it possible to get the source code to the Windows GUI for the

Sensor Fusion Toolbox? What I'm trying to do is just capture the compass

heading (in degrees) after all the offsets and calibration have been

calculated (as is displayed in the text box in the Sensor Fusion Toolbox

GUI)? Thank you again.

Randy

<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>

Virus-free.

www.avg.com

<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Dec 1, 2017 at 11:11 AM, michaelestanley <admin@community.nxp.com>

0 Kudos

833 Views
michaelestanley
NXP Employee
NXP Employee

Randy,

You can read the compass heading directly from the global structures.  The field name varies as a function of the algorithm you're using.  See Section 4.2 in the user manual, and specifically Table 6.  The forth row in the table gives you the field name.

Let me know if you're still interested in the GUI after checking that out.  We're in the process of adjusting our software release processes in anticipation of the QualComm merger, and I'll need to consult my masters about doing that within the scope of new guidelines.

Regards,

Mike

0 Kudos

833 Views
randyjohnson
Contributor II

Thank you, Mike. I was able to read the compass data and might not need the

Windows GUI. A few questions:

1. Is the Sensor Fusion Toolbox flashed onto the K64F when I run the

Windows Sensor Fusion Toolbox and thereafter the Windows GUI is reading the

processed or calibrated compass fRhoPl heading from the board itself, or is

the Sensor Fusion Toolbox a Windows program that is constantly pulling the

raw data from the K64F and processing the calibrations in a Windows .exe?

2. If the Toolbox software is actually on the board and running from the

board, could I just create my own Windows GUI and pull the calibrated

compass data from the serial port, and if so, what header files or library

files do I need to include in my Windows C# program?

3. When I first run the Windows Sensor Fusion Toolbox, it asks the user to

move the board around to calibrate it. This being the case, when I run the

debug in the MCUXpresso IDE and read the fRhoPl data, how does the Sensor

Fusion software initially calibrate the sensors? When running the debugger,

it doesn't ask me to wave the board around as does the Windows Sensor

Fusion program.

Thank you for your help. Very grateful.

Randy

<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>

Virus-free.

www.avg.com

<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Dec 1, 2017 at 2:01 PM, michaelestanley <admin@community.nxp.com>

0 Kudos

833 Views
michaelestanley
NXP Employee
NXP Employee
  1. "Sensor Fusion Toolbox" refers to the GUI portion only running under windows or Android.  It communicates to a sensor fusion application running on the embedded board via a UART-based protocol which is documented in the user guide.  The GUI has the ability to program boards with a sample S.F. application.  But that is NOT what you've done.  You've used the development tool to program the board, which is the normal development flow.  ALL calibrations are done on the embedded board.  The GUI is for demo and debug purposes only.
  2. You can create your own windows app if desired.  Again, the protocol is specified in the user guide.  And since you have source, you can even change it if desired.  We don't normally supply Windows-side software or headers, as most customers have their own interfaces.
  3. calls to initialize the accel and mag calibration parameters are inside function initializeFusionEngine() in file sensor_fusion.c.  The initialization functions for the 6 and 9-axis Kalman filters will either load previously stored gyro offsets from flash OR just use current measurements as the offset.  The latter is why you see that message in the GUI.

Much of the above IS covered in the user guide.  You will save yourself a lot of time if you take the time to at least give it a quick skim so you know what is covered.  I also posted links to training videos in this space yesterday.

Good luck.

Mike

0 Kudos

833 Views
randyjohnson
Contributor II

To add to this.....I've tried writing "Q9 " to the K64F through the serial

port in my Visual C# project then calling ReadExisting() to read data from

the serial port. ReadExisting gives me an empty string.

The only time ReadExisting gives me any data is when I first plug in the

K64F, and when it does give me data it is undecipherable. After the first

read, in the following calls to ReadExisting it gets an empty string. The

ReadLine command gets data, but it appears to be undecipherable as well.

0 Kudos

833 Views
michaelestanley
NXP Employee
NXP Employee

Randy,

You probably don't want to think of the board as a programmable USB peripheral.  That's not the intent.  The GUI uses the OpenSDA UART/USB feature to communicate with the board.  So it has to have the appropriate OpenSDA driver installed on your windows machine - which only embedded developers are likely to have.   The interface in the embedded code has communications to/from the sensor fusion toolbox as it's primary reason for existence.  But of course you are welcome to use it as a starting point for your application.  The protocol (covered in ch. 7 of the user guide) is binary.  So you should not expect to see human readable content in your console.  Nor can you send it ascii commands.  The embedded code is almost always streaming packet types 1, 3 and 4 at a minimum.  You use Sensor Fusion Toolbox commands to select which algorithm is being used to compute the data in those packets.

Shoot me an email at mike.stanley@nxp.com with your contact info and I'll check on my end to see how I can put the C# file that I use to communicate with the board into your hands.

Regards,

Mike

0 Kudos

833 Views
randyjohnson
Contributor II

Thank you Mike for your help. I've studied everything available that I

could find and still stuck. With typical USB hardware peripherals I've

programmed to in the past, they have *.dll file(s) I can import into my

Visual Studio C# project and use the hardware's custom API data structure

calls and send them through the virtual USB to get the data. I've never

worked with an embedded system so, while I understand the basics of how it

works, I'm having trouble with the syntax to request specific data from the

K64F-AGM01. I connect to the port through my C# project and send a ReadLine

command. The information I get back is hex numbers. Is this what I should

expect? If so, how do I translate them? (As a side note, when I hook the

K64F board up to Tera Term, the console just prints a stream of garbage) I

was hoping to be able to just send a request to the port from my C# project

to get the fRhoPl data from the K64F. If there is a simple line of C code

from my C# project to do this, I haven't found it. I see there's a

sUARTOutputBuffer in the bare metal code. Is that where can pick up the

data from the host? If so, how? Should I write lines of code in the bare

metal main program to actually send information to the port, then read it

from the port on the host (C# project) side?

Thanks in advance,

Randy

<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>

Virus-free.

www.avg.com

<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>

<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Sat, Dec 2, 2017 at 7:54 AM, michaelestanley <admin@community.nxp.com>

0 Kudos