View previous topic :: View next topic |
Author |
Message |
BLL
Joined: 11 Nov 2006 Posts: 181 Location: Birmingham, UK
|
10F206 |
Posted: Wed Oct 17, 2018 1:48 pm |
|
|
Hi,
I am trying to use a 10F206 for the first time.
I want to use idiv, which the help says is available for all devices.
However, when I add #include <stdlib.h>, I get a raft of errors, the first being char digits[]="0123456789abcdefghijklmnopqstuvwxyz"; data item too long!
So, is idiv not for all devices or how do I stop all these errors please?
Brian |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Wed Oct 17, 2018 2:03 pm |
|
|
I just looked at the data sheet, 512 words for program, 24 bytes for RAM. You don't show your complete program but I suspect you're out of memeory !
Your array is 37 bytes so that exceeds the RAM amount..
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Wed Oct 17, 2018 2:08 pm |
|
|
It's complaining, because the amount of RAM in the chip is so small that it 'knows' it can't actually store this array if required to. However this is part of the strtoul function, not the div function (the function is actually div, not idiv).
So simply REM this function out. Add a /* the line in front of strtoul, and a */ the line after the end of the function, save the result with your project, and change the load to #include "stdlib.h", which will make it load the local copy.
The core reason is simply that the manual section here 'predates' the introduction of these ultra small chips.
However be aware that you are unlikely to be able to do anything actually with the function. The amount of RAM in the chips is so small that you will not have space to do pretty much anything involving division....
Code: |
#include <10F206.h>
#use delay(internal=4MHz)
#include "stdlib.h"
void main()
{
div_t val;
val=div(3,2);
while(TRUE)
{
}
}
|
On it's own uses 79% of the available RAM in the chip... |
|
|
BLL
Joined: 11 Nov 2006 Posts: 181 Location: Birmingham, UK
|
10F206 |
Posted: Wed Oct 17, 2018 3:05 pm |
|
|
Hi respondents and thanks for the suggestions.
It is now working, but using 92% RAM!
Thanks
Brian |
|
|
|