• AVR Freaks

Harmony V1.09 USB corrupting RAM

Author
laffelt
Super Member
  • Total Posts : 143
  • Reward points : 0
  • Joined: 2008/05/08 18:05:53
  • Location: 0
  • Status: offline
2017/03/30 14:47:54 (permalink)
0

Harmony V1.09 USB corrupting RAM

I have a project running in Harmony V1.09 for several months now, uses as little of Harmony as possible for USART, SPI, I2C, Timer, and SQI. Now it's time to turn on the USB port with which I only need to read and write files to a USB flash drive.
 
So I confirm that my USB clock is proper at 48MHz, turn on USB Stack, Interrupt Mode, USB Host, USB_SPEED_HIGH, 1 Device, 1 TPL Entry, Host Max Interface per device 5, and Use MSD Host Client Driver (image attached). When saving the updated system files from the framework I see new entries as expected, new SYS_OBJECT items, configuration data for USB/USB Host/MSD, and _Init() and _Task function calls as expected. I have added no calls to use the USB port, so only the initialization calls are being made along with the task calls in the main loop.

Now when my project runs I see some of my graphic objects changing color on the screen as I flip through different windows, one object especially. I detect that something is changing the values in that object's color palette struct so I drop into debug mode and set a breakpoint on writing to those palette object's address in RAM. Once I step through the breakpoints happening during my initialization of the palette data I soon catch more breakpoints triggered and see the data in my structs being changed. Ok, I can see it happening ... In the Stack window MPLAB reports that there is no code at the address causing the data corruption, so I open the linker map file and using the PC address provided I see that it is happening in the library function 'fputs' ... Reminder that I am not opening, writing, of closing files with the USB!
 
Has anyone seen anything like this? Has anyone gotten the USB running on a PIC32MZ using Harmony? Any help would be greatly appreciated!

Project particulars: PIC32MZ2048EFH144, Harmony V1.09, XC32 V1.42, and MPLABX V3.51

Larry

Attached Image(s)

#1
NKurzman
A Guy on the Net
  • Total Posts : 17939
  • Reward points : 0
  • Joined: 2008/01/16 19:33:48
  • Location: 0
  • Status: online
Re: Harmony V1.09 USB corrupting RAM 2017/03/30 22:59:58 (permalink)
4 (2)
Read your post again and see if it is clear to you.
So you are using Harmony for uart, spi,SQI, the timer(s) and the graphics?
You are using USB in Host Mode and the MSD driver. Do you have the file system setup an configured properly for this?
Harmony is not robust. It does not always check if underlying services exist. It does not alway trap null pointers. So verify everything you need is there. Compare your app to one of the samples.
#2
laffelt
Super Member
  • Total Posts : 143
  • Reward points : 0
  • Joined: 2008/05/08 18:05:53
  • Location: 0
  • Status: offline
Re: Harmony V1.09 USB corrupting RAM 2017/03/31 08:06:53 (permalink)
0
NKurzman ... "Harmony is not robust." ... lol
Here is the extent Harmony is used in my project:
Oscillator configuration, also a REFCLK output to my graphics chip
I2C & SPI - Marmony initializes port only, my code using SFR's after that, no calls to Harmony or PLIB
Timer - Harmony used to create 1mS interrupts on Timer1 which I hooked 
UART, CAN, SQI - No Harmony code, SQI only sets port pins anyway
Graphics - Not using Microchip system at all, FTDI FT810 through the SPI port
 
Comparing to the example I found, I found that my sysfsMountTable[] was empty in system_config.h. Found difference in Harmong config, changed File System in System Services to MSD from SD Card and turned on Auto Mount and table was filled in.
 
Rebuilt my program, same problem ... I will keep digging ...
 
Thanks ...
#3
laffelt
Super Member
  • Total Posts : 143
  • Reward points : 0
  • Joined: 2008/05/08 18:05:53
  • Location: 0
  • Status: offline
Re: Harmony V1.09 USB corrupting RAM 2017/03/31 13:33:34 (permalink)
4 (2)
Ok, found it. It was not the actual USB and MSD code, but bringing that into the system moved some of my data arrays around and one buffer was being overwritten (first time I've ever done that! ... lol)
 
Just plugged a USB flash drive in and the system mounted it, and unmounted it when I unplugged it.
 
Thanks for the help!
#4
Jump to:
© 2019 APG vNext Commercial Version 4.5