Created Fri, 08 Jul 2011 06:03:18 +0000 by electroscott
Fri, 08 Jul 2011 06:03:18 +0000
First, thanks for the terrific PIC32MX board! I am using it in conjunction with another PIC32MX to help offload some of my robotic processes for a 4WD rover. The rover, with its 6-channels of radio control, servos, 25 kHz PWM (4 motors) and full 4x quadrature encoder interface was a bit taxed, so this additional board is perfect.
I'm not using the Arduino-type IDE. I'm using MPLAB IDE v8.73. I'm also programming via ICD3 (and its representative adapter cable). I'm able to program and debug the MAX32 without troubles and have verified that the code works.
I'm having a strange problem now, though. I am using digital ports 70-73 for four servos centered at 1500 us with 3 us resolution. Code is tested and working. Making use of timer 3 and interrupts to handle a simple tick countdown of the 3 us tick period before setting the port back low. This way, my gripper arm gets updated at the same time (necessary because I have an IMU on the gripper for a feedback controller). The servos work fine as long as I program the board using the debug executive, and I can simply push "play" in the IDE and the servo goes. I can add breakpoints, step through the program, etc., and it's really just bare bones for this aux board.
However, when I enter regular program mode and use the ICD3 without its debug executive, I can't get the servos to work. I have a heartbeat output that toggles once every loop cycle (100 Hz) and it is running properly.
My config settings are:
// Configuration bits #pragma config UPLLEN = ON // USB PLL Enabled #pragma config FPLLMUL = MUL_20 // PLL Multiplier #pragma config UPLLIDIV = DIV_2 // USB PLL Input Divider #pragma config FPLLIDIV = DIV_2 // PLL Input Divider #pragma config FPLLODIV = DIV_1 // PLL Output Divider #pragma config FPBDIV = DIV_1 // Peripheral Clock divisor #pragma config FWDTEN = OFF // Watchdog Timer #pragma config WDTPS = PS1 // Watchdog Timer Postscale #pragma config FCKSM = CSDCMD // Clock Switching & Fail Safe Clock Monitor #pragma config OSCIOFNC = OFF // CLKO Enable #pragma config POSCMOD = HS // Primary Oscillator #pragma config IESO = OFF // Internal/External Switch-over #pragma config FSOSCEN = ON // Secondary Oscillator Enable (KLO was off) #pragma config FNOSC = PRIPLL // Oscillator Selection #pragma config CP = OFF // Code Protect #pragma config BWP = OFF // Boot Flash Write Protect #pragma config PWP = OFF // Program Flash Write Protect #pragma config ICESEL = ICS_PGx2 // ICE/ICD Comm Channel Select #pragma config DEBUG = ON // Background Debugger Enable
My code works fine in my USB PICStart variant, so this has me a bit perplexed. Any ideas why when I operating with a debug executive, my timer 3 interrupts work fine, but when I run with a normal, release version, my timer 3 interrupts fail to execute?
Thanks, --Scott Thompson
Fri, 08 Jul 2011 11:18:09 +0000
The debugger executive does some chip initialization that you may be inadvertently relying on...
For example, from: [url]http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1406&dDocName=en533048&redirects=icd2Help#P87_11618[/url]
Resolution: In debugger-mode the Debug Executive is configuring some pins to be digital I/O. In programmer mode this is not the case, which leaves the QEA and QEB in (default) analog mode. Make sure that your program properly configures this peripheral and pins.
If you have the ability to get data out of your MCU when it is running (like a serial port), you might try dumping (all) the SFRs when you first get control of the MCU.
Comparing the initial SFR values when running with the debugger executive and when not might lead you to a register you are forgetting to initialize (and the debugger executive is incidentally doing for you)...
I'm assuming you don't have an issue with the differences between a debug and release build with regard to compiler optimization levels or __DEBUG definitions (which for example in my code can cause assert statements and other debugging code to become live or not).
Fri, 08 Jul 2011 14:18:44 +0000
Edit: Fixed issue. Problem was I needed to turn off the JTAG interface from DDPCON :oops:
Thanks for the help.