View previous topic :: View next topic |
Author |
Message |
Raven
Joined: 08 Jan 2004 Posts: 3
|
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Jan 08, 2004 7:47 am |
|
|
You should be able to use a 16F876 instead. There is a demo of the compiler that will allow to you compile the code and since the device is flash based you can reprogram it. The demo might only be for the 16F877 but it should still work in the 16F876. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
Compile |
Posted: Thu Jan 08, 2004 8:47 am |
|
|
I get a "Not Enough RAM for Variables" message when I try to compile this for you.
However, it compiles with no problems for the 16C76 here are the statistics (notice that Worst Case RAM is the problem, you only have 192, so you may be able to fix this with some reorganization):
ROM used: 2545 (31%)
2048 (25%) including unused fragments
2 Average locations per line
6 Average locations per statement
RAM used: 150 (41%) at main() level
205 (56%) worst case
Lines Stmts % Files
----- ----- --- -----
823 454 100 C:\My Download Files\smack_pic.c
215 0 0 C:\CCS_C\PICC\devices\16c76.h
----- -----
2076 908 Total
Page ROM % RAM Functions:
---- --- --- --- ----------
0 14 1 0 @GETCH_BIU_1
0 172 7 4 InitialiseMotors
0 42 2 3 rda_handler
0 28 1 1 tbe_handler
0 5 0 0 allowNewMessage
0 37 1 4 startMotor
0 194 8 6 timer1_handler
0 21 1 3 stopMotor
0 25 1 5 @MUL1616
0 630 25 6 UpdateMotorQ
0 103 4 6 CheckLimits
1 1203 47 0 main
Segment Used Free
--------- ---- ----
00000-00003 4 0
00004-00046 67 0
00047-007FF 1271 706
00800-00FFF 1203 845
01000-017FF 0 2048
01800-01FFF 0 2048 |
|
|
Raven
Joined: 08 Jan 2004 Posts: 3
|
Compile |
Posted: Thu Jan 08, 2004 9:16 am |
|
|
Hi Dyeatman
You wrote you tried to compile it to 16C76- Is there any difference between this and Pic 16C73A when compiling.
Thanks for your help so far! :-)
Kristoffer Raun |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
Compiling Stepper project |
Posted: Thu Jan 08, 2004 3:22 pm |
|
|
I did this purely because the 76 has more memory since the 73 compile came up short on memory and to see if there were any other compile time code problems, which there were not.
Code wise the program should compile fine on the 73 when you get the memory usage down a bit. Whether it runs correctly is another story....can't do much about that here since I don't have any of the hardware... |
|
|
Raven
Joined: 08 Jan 2004 Posts: 3
|
Compile |
Posted: Thu Jan 08, 2004 6:35 pm |
|
|
Hi Dyeatman
Thanks a lot for your good answer!
I'm a beginner into this PIC'ing, but i'm wondering if it's possible to compile it , even thought that there isn't enough space for the variables?
Anyway i will try to get the memory usage down and hopefully this will work.
How much does the compiled program use at the moment and how much do i have to cut it down?
Thanks in advance
Kristoffer Raun |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
Stepper Project |
Posted: Thu Jan 08, 2004 9:46 pm |
|
|
According to the stats I provided in the earlier reply:
ROM used: 2545 (31%)
2048 (25%) including unused fragments
2 Average locations per line
6 Average locations per statement
RAM used: 150 (41%) at main() level
205 (56%) worst case
The problem is in the last line above (205 worst case) meaning that you require 205 RAM positions worst case but only 150 in the main program (you have 192 RAM to play with in the 73) sooooo you need to work on eliminating/combining/reusing variables as much as possible to get the worst case number down to below 192 (-13 decrease) which should be possible with a little analysis.
You have plenty of ROM left (73 has 4096) so RAM is your main issue at this point.
Good Luck!
dave |
|
|
Raven
Joined: 08 Jan 2004 Posts: 3
|
Compiling |
Posted: Fri Jan 09, 2004 4:07 am |
|
|
Hi Dave
Thanks a lot - I will give it a try to reuse some of the variables.
Tell me - what happens if i use this program and put it into the pic, and the used ram amount exceed 192?
Best Regards
Kristoffer |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
Compiling |
Posted: Fri Jan 09, 2004 7:22 am |
|
|
Theoretically, the program should not exceed the worst case spec the compiler generates. Therefore the prgram should not compile if the compiler sees a possiblility of running out of RAM. However, that doesn't mean it can't happen(never say never!). If it does, a program crash will likely occur depending on circumstances or at best a program anomaly of some kind (??).
Dave |
|
|
Raven
Joined: 08 Jan 2004 Posts: 3
|
Compiler |
Posted: Fri Jan 09, 2004 9:13 am |
|
|
Hi Dyeatman
Thank again for your answer.
I have looked thru the code and have found a limit switch-function which we aren't going to use - i will delete this function from the code and hopefully this should give me the last 13.... :-)
Another question - I see in the code that the baudrate is fixed to 1200 baud.
#use rs232(baud=1200,xmit=PIN_c6, rcv=PIN_c7,errors)
Is it possible for the pic to use a higher baud rate with the 16C73A ?
#use rs232(baud=9600,xmit=PIN_c6, rcv=PIN_c7,errors)
What's the limit?
Best Regards
/Kristoffer
Last edited by Raven on Fri Jan 09, 2004 9:21 am; edited 1 time in total |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Fri Jan 09, 2004 9:20 am |
|
|
With a 10MHz crystal you can do 57600 with a small % error. If 9600 is fast enough for you, that would be ideal. |
|
|
Raven
Joined: 08 Jan 2004 Posts: 3
|
Compile |
Posted: Fri Jan 09, 2004 11:16 am |
|
|
Hi
Thank you Mark for your answer - i have set it to 9600, this should be adequate.
I have removed a limit function to control some limitswitches that we dont need. This could give the needed space.
http://www.pfg.dk/smack_pic.c
Best Regards
Kristoffer
Last edited by Raven on Fri Jan 09, 2004 12:05 pm; edited 1 time in total |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Fri Jan 09, 2004 12:44 pm |
|
|
This is what I get with an older version of the compiler
CCS PCM C Compiler, Version 3.089, 12084
Filename: test.LST
ROM used: 2457 (60%)
Largest free fragment is 851
RAM used: 141 (73%) at main() level
187 (97%) worst case
Stack: 4 worst case (2 in main + 2 for interrupts)
So yes, it compiled |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
Compiler |
Posted: Fri Jan 09, 2004 2:44 pm |
|
|
I get the same statistics for 3.182 (as shown below) so you seem to have that much taken care of. It compiles fine for me as well...
Dave
=============
ROM used: 2140 (52%)
985 (24%) including unused fragments
2 Average locations per line
5 Average locations per statement
RAM used: 141 (73%) at main() level
187 (97%) worst case
Lines Stmts % Files
----- ----- --- -----
779 428 100 C:\My Download Files\smack_pic.c
215 0 0 C:\CCS_C\PICC\devices\16c73.h
----- -----
1988 856 Total
Page ROM % RAM Functions:
---- --- --- --- ----------
0 13 1 0 @GETCH_BIU_1
0 124 6 3 InitialiseMotors
0 30 1 2 rda_handler
0 24 1 1 tbe_handler
0 5 0 0 allowNewMessage
0 24 1 3 startMotor
0 160 7 5 timer1_handler
0 18 1 2 stopMotor
0 32 1 5 @MUL1616
0 559 26 5 UpdateMotorQ
1 1063 50 0 main |
|
|
Guest
|
Re: Stepper project problems - CCS C PCM Compiler |
Posted: Fri Jun 04, 2004 8:26 pm |
|
|
|
|
|
|