![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
First off, Microchip needs fix their crap. Half of the example code in the C18 guide does not work with the compiler. Even some of the code supplied with the compiler!
Question 1: how do I use the "-p18f4685" command line option? From what it tells me, it should be: "mcc18 -p18f4685". But this does not work (syntax error!) Question 2: I get the message: "Error - section '.tmpdata' can not fit the section. Section '.tmpdata' length=0x00000020" This happens whenever I uncomment the function I have that crunches through some IK equations. I have no idea how to fix this, or why the problem exists. I am assuming that the reserved .tmpdata variable section is not big enough. How would I create a new temp data section and have the function use that? Microchip really needs to read their own stuff. Last edited by Ambient; 18th February 2008 at 10:13 PM. |
|
|
|
|
|
|
(permalink) |
|
Why does it use sections anyways? This is very frustrating. Here is how I defined the variables so far. Most of them are used by the void IK(void) function.
#pragma udata access my_access near float tempIK1,tempIK2,tempIK3; near float leg,m,n,X,Y,Z; near unsigned int Hip_Height; //Hip joint height near unsigned int Body_Height; //bottom chassis clearance near float Tmp_Angle,HipH_Angle,HipV_Angle,Knee_Angle; near float Ltotal,l,ltemp; #pragma romdata rom unsigned float Femur_L = 57; rom unsigned float Tibia_L = 143; rom unsigned float Hip_L = 28; #pragma code void IK(void) { //IK trig equations } |
|
|
|
|
|
|
(permalink) |
|
I broke up the one function into 3 functions. But now it says that the MATH_DATA has that same problem. If I use any cosine, sine, etc. functions it tells me:
"Error - section 'MATH_DATA' can not fit the section. Section 'MATH_DATA' length=0x00000014" What a crappy compiler. Any suggestions? It won't even let me use ONE cos() function. Last edited by Ambient; 18th February 2008 at 09:42 PM. |
|
|
|
|
|
|
(permalink) |
|
Hi Ambient,
Just guessing here as I haven't used PICs (just some older 8051s so far) but: if those are true trig functions then perhaps it's the floating point math which doesn't fit. I've seen a smaller uC choke on floating point before, so I changed the code to fixed point to get around the space limitation. One common way to speed up and shrink trig functions is to use lookup tables instead of the floating point math functions. I don't know whether C18 internally uses the floating point routines though, so this might not even be your problem. Anyway, good luck! Torben |
|
|
|
|
|
|
(permalink) |
|
These are built-in trig functions included in a header file. So they probably do not use a lookup table. The functions specify that they take in a float and output a float.
|
|
|
|
|
|
|
(permalink) |
|
Can you show us the linker script you're using?
P. PS: the compiler's error messages are crap... the compiler itself is fine. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
One I found: http://www.brouhaha.com/~eric/pic/sine.html It'll take someone who is familiar with the PIC18 to tell you whether you need to do this or not for sure, but I generally try to avoid floating point unless I either have lots of spare space and speed is not important, or there is hardware support for it. Torben |
||
|
|
|
|
|
(permalink) |
|
Thanks. There is lots of space, 96k program, 3,328 bytes RAM. A lookup table is going to have to work if I can't solve this.
I guess I am just using the linker for the 18f4685 that comes with C18. That is the only linker I specified when I started the project. Is that what you need to see? I am hoping to get this resolved somehow, I wanted to get the robot walking so I can take it on my interview lol. Last edited by Ambient; 18th February 2008 at 11:50 PM. |
|
|
|
|
|
|
(permalink) |
|
I think I figured it out. Since the PIC has banks, it has to split up these memory sections that it uses. I then realized that maybe the MATH_DATA was trying to fit into the access bank. But I had already declared my udata section to be in the access ram. I got rid of the access ram variables, not it works. How annoying.
|
|
|
|
|
|
|
(permalink) |
|
I think I figured it out. Since the PIC has banks, it has to split up these memory sections that it uses. I then realized that maybe the MATH_DATA was trying to fit into the access bank. But I had already declared my udata section to be in the access ram. I got rid of the access ram variables, now it works. How annoying.
|
|
|
|
|
|
|
(permalink) |
|
Welcome to the world of banked memory.
__________________
search engine for electronic partsJunebug USB PIC programmer kit., USB Bit Wacker, Homepage The 15 Minute Printed Circuit Board! (+drill time) |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Torben |
||
|
|
|
|
|
(permalink) |
|
Now I just gotta finish the damn thing lol. I have till next wed. Hopefully I can get the hexapod moving by then at least. I just got in the servo controller, which accepts serial commands. So that is the next part.
Anyone know where the command line is for specifying the processor? I thought it would be in the source code, but I have a feeling now that it is somewhere in the options. Last edited by Ambient; 19th February 2008 at 10:16 PM. |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Whitfield Pellet Stove Problems | Sheriffjer | General Electronics Chat | 6 | 1st November 2007 01:36 PM |
| USB to Serial problems | spondootre | Micro Controllers | 12 | 28th November 2006 08:09 AM |
| Surge problems | leonel | Electronic Projects Design/Ideas/Reviews | 3 | 15th September 2006 02:36 PM |
| Problems with 12 hour clock | IlordrossI | Electronic Projects Design/Ideas/Reviews | 4 | 1st March 2005 12:20 AM |
| Report in problems of 3 phase rectifiers | Ziyad_noel | General Electronics Chat | 0 | 11th October 2003 06:05 PM |