Hi,
I've got all my code running and I run from flash just fine if I boot from JTAG through Code Composer v4. When I turn off power and try to boot the 2801 doesn't boot.
I read through SPRA958 and noticed in section 4.1 that I need to copy the PIE Vector Table to RAM. I'm not doing this yet that I know (unless it's buried in the TI supplied headers/.c files) so I tried inserting the code shown into my main.c. The compiler came back and stated it couldn't find &PieVectTableInit. I know it's in the PieVect.c file but my main doesn't see it.
Should this code go into the PieVect.c file?
Is this code really needed since I'm already running out of flash when booting from JTAG?
Please help. This is my last problem to solve before I deliver to my customer.
Update:
I just noticed I'm not doing all of section 4.4 (of SPRA958) either unless this also is taken care of by the TI supplied headers/.c files. I have InitFlash in my main.c and InitFlash function in my SysCtrl.c but I don't have the "User's linker command file" stuff in F2801.cmd or Headers_nonBIOS.cmd.
Also, SPRA958 shows:
asm ("RPT #6 || NOP")
My SysCtrl.c has: asm ("RPT # || NOP") Is this an issue?
My SysCtrl.c has:
asm ("RPT # || NOP")
Is this an issue?
My product appears to boot up and go through an initialization test where it runs my motor for 200 ms and then turns on the brake. I'm pretty sure it is doing this because before I put in the brake it would run the motor and the motor would just spin down instead of stopping. After I put in the brake command, the motor spins and then comes to an abrupt halt indicative of what I have in my startup test. After that, I don't get my CAN communication.
I'm assuming the problem is associated with moving the PieVectTable to RAM.
Can someone help with this? Please refer to the above post with regards to the moving the Pie table issue.
Thanks,
Rick
Richard Shank Hi, I've got all my code running and I run from flash just fine if I boot from JTAG through Code Composer v4. When I turn off power and try to boot the 2801 doesn't boot. I read through SPRA958 and noticed in section 4.1 that I need to copy the PIE Vector Table to RAM. I'm not doing this yet that I know (unless it's buried in the TI supplied headers/.c files) so I tried inserting the code shown into my main.c. The compiler came back and stated it couldn't find &PieVectTableInit. I know it's in the PieVect.c file but my main doesn't see it. Should this code go into the PieVect.c file? Is this code really needed since I'm already running out of flash when booting from JTAG? Please help. This is my last problem to solve before I deliver to my customer.
Richard,
For debugging stand-alone boot I would like to suggest the debug tips on this wiki page. Hopefully it can help narrow down the problem:
http://processors.wiki.ti.com/index.php/C2000_Flash_Common_Issues/FAQs#Code_Does_Not_Run_Standalone
You may want to take a look at the simple example called "flash" included in the 280x header files and peripheral examples:
http://focus.ti.com/mcu/docs/mcuprodcodeexamples.tsp?sectionId=96&tabId=1470
The example is in: C:\tidcs\c28\DSP280x\v160\DSP280x_examples\flash
In this code, the "InitPieVectTable();" initalizes the PIE vector table to default ISR routines (they don't do anything - just place holders.)
To assign your own vector, the code is the same in RAM or in Flash - here is an example. This changes the EPWM1_INT interrupt vector to point to the epwm1_timer_isr, and soforth. The cut from the example is shown below:
// Interrupts that are used in this example are re-mapped to// ISR functions found within this file. EALLOW; // This is needed to write to EALLOW protected registers PieVectTable.EPWM1_INT = &epwm1_timer_isr; PieVectTable.EPWM2_INT = &epwm2_timer_isr; PieVectTable.EPWM3_INT = &epwm3_timer_isr; EDIS; // This is needed to disable write to EALLOW protected registers
Richard ShankI just noticed I'm not doing all of section 4.4 (of SPRA958) either unless this also is taken care of by the TI supplied headers/.c files. I have InitFlash in my main.c and InitFlash function in my SysCtrl.c but I don't have the "User's linker command file" stuff in F2801.cmd or Headers_nonBIOS.cmd.
If I understand, you are not specifying a run and load address for functions that are in the ramfuncs section. This can be a issue in particular with the InitFlash. The flash configuration can not be changed while running from the flash itself. Doing so can cause the code to ITRAP. The InitFlash function needs to be loaded into flash and then copied to RAM for runtime.
In the C28x header files and peripheral examples, the InitFlash is assigned to the ramfuncs (different than shown in that application note).
Richard Shank Also, SPRA958 shows: asm ("RPT #6 || NOP") My SysCtrl.c has: asm ("RPT # || NOP") Is this an issue?
Yes, the repeat needs to be at least #6 in order to flush the pipeline. The DSP280x_SysCtrl.c on my machine has #7.
Regards,
Lori
Richard Shank Update: My product appears to boot up and go through an initialization test where it runs my motor for 200 ms and then turns on the brake. I'm pretty sure it is doing this because before I put in the brake it would run the motor and the motor would just spin down instead of stopping. After I put in the brake command, the motor spins and then comes to an abrupt halt indicative of what I have in my startup test. After that, I don't get my CAN communication. I'm assuming the problem is associated with moving the PieVectTable to RAM. Can someone help with this? Please refer to the above post with regards to the moving the Pie table issue. Thanks, Rick
To see if it is the vectors, I suggest trying the debug step described on this wiki:
When stepping through the code, check the PIE vector table itself to see if the vectors are populated correctly.
Hi Lori,
Thanks for your help. I used the debug method from the wiki and I don't really know how to "load symbols only". I did step through the program and it appears the CAN is not working. It works fine if I boot off of JTAG but when I recycle power the CAN stops working. I don't have CAN in my MemCopy to ramfuncs. I didn't see anywhere that shows how to copy the CAN to MemCopy. Could this be the issue.
Incidentally, there is a typo above with regards to my SysCtrl.c. It has asm (RPT #7 || NOP"). The word formatter on this web page went nuts on me that day and I had to type it in 5 times and I missed the typo the last time.
Thanks again,
Richard Shank I did step through the program and it appears the CAN is not working. It works fine if I boot off of JTAG but when I recycle power the CAN stops working. I don't have CAN in my MemCopy to ramfuncs. I didn't see anywhere that shows how to copy the CAN to MemCopy. Could this be the issue.
I did step through the program and it appears the CAN is not working. It works fine if I boot off of JTAG but when I recycle power the CAN stops working. I don't have CAN in my MemCopy to ramfuncs. I didn't see anywhere that shows how to copy the CAN to MemCopy. Could this be the issue.
Generally differences between running code from Flash and from RAM are timing issues. This may or may not be the case with your CAN code. However, I recommend putting any time crictical code, particularly ISRs to run from RAM. This is simply done by placing them in the ramfuncs section using the #pragma.
e.g.
#pragma CODE_SECTION(CAN_ISR, "ramfuncs")
This will copy the code to RAM when all the rest of the ramfuncs code is copied.
Richard Shank Thanks for your help. I used the debug method from the wiki and I don't really know how to "load symbols only".
Thanks for your help. I used the debug method from the wiki and I don't really know how to "load symbols only".
Try this (only partially tested but I think it does the trick):
1) Target Menu -> Launch TI Debugger
2) Target Menu -> Load Symbols. Choose your program
3) Target Menu -> Connect Target
Tim
Thanks Tim but I'm running from flash. I can boot from JTAG running out of flash and it runs fine but when I cycle power, it comes up and runs my program but I don't have CAN anymore.
I'll try loading the CAN_ISR to ramfuncs.
Thanks All,
I had to pack the unit up to ship to the customer and I'm going to the customer for a couple days tomorrow so I didn't get a chance to try the latest suggestions. If I get time, I'll try the above at the customer's or I'll try to get to it some time next week. We also have CDR next week so it will be busy.
I'll get back to you as soon as I get time to test this.
Again, thanks for the help.
Any luck, Rick?
After CDR I've been busy with my hardware to do list as I had to clean up a board and get a new one on order. I have one final hardware test to do today and then I'm back on to software. This issue is the first on my list. I'll be back soon.
I've stepped through the initialization code from the flash entry to my "check for a CAN message" step. I don't see anything wrong but I'm not a software guru either. I do see where it appears I'm moving the pie vector table from flash to ram twice. The first one was already in DSP280x_PieVect.c. The second one is the memcpy I added because I wasn't sure the first one existed. Here is a clip from my PieVect.c.
7870.DSP280x_PieVect.pdf
I'm still lost as to what the problem is. It appears to not see a CAN input. The code is there (not sure it is correct) but the CAN message is not recognized as being received. Again, this works fine if I boot off the JTAG. I can completely disconnect the JTAG after I boot and I run fine. If I turn off power, the processor won't recognize the CAN until I boot through JTAG. Every thing else in the code seems to work ok.
Here is a screen shot of the C and assembly code where the code isn't working.
Richard Shank I'm still lost as to what the problem is. It appears to not see a CAN input. The code is there (not sure it is correct) but the CAN message is not recognized as being received. Again, this works fine if I boot off the JTAG. I can completely disconnect the JTAG after I boot and I run fine. If I turn off power, the processor won't recognize the CAN until I boot through JTAG. Every thing else in the code seems to work ok.
This may be caused by one of your functions not being mapped into flash properly and thus only works when RAM is loaded (i.e. JTAG). Just a possibility. Are you able to post a copy of your .map file?
Hi Tim,
To my knowledge, I'm running from flash even when I boot from the JTAG. Anyway, here is my .map file.
1321.VGC.pdf
From your map file it seems what you say is true, that you are running the majority of your code from flash. However, the sections ramfuncs and .cinit seem to reside in RAM. These are sporadically used functions but may make a difference. Am I able to see your linker file?
Thanks Tim. Here it is. I'm just using the F2801.cmd from the kit. I haven't changed anything.
8284.F2801DOTcmd.pdf
Rick,
In the linker command file there are sections that have a load address into flash and a run address in RAM.
ramfuncs : LOAD = FLASHD, RUN = RAML0, LOAD_START(_RamfuncsLoadStart), LOAD_END(_RamfuncsLoadEnd), RUN_START(_RamfuncsRunStart),
Have you copied the functions from their load address into their run address? In our examples this is done with a memcopy routine just inside of main(). Make sure this is first - if you setup the PLL or ADC before doing this you can find yourself in one of these functions that has not been copied.
-Lori