View previous topic :: View next topic |
Author |
Message |
roger_cris
Joined: 02 May 2014 Posts: 5
|
scanf() 16F887 |
Posted: Fri May 02, 2014 9:33 am |
|
|
Hello,
I try to implement scanf() after reading http://www.ccsinfo.com/newsdesk_info.php?newsdesk_id=159, but after compiling generates an error Error#12 Undefined identifier -- scan.
Using MPLABx with ccs plug in 1.57.
I have included stdio.h.
Code: |
#int_rda //Interrupção RS485
void RDA_isr()
{
scanf ("%c %u %c", prefix, addr, act);
//in_char = fgetc(rs485);
}
|
Can you give any help regarding this issue?
Thank You! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Fri May 02, 2014 9:45 am |
|
|
Maybe a silly question but what version of the compiler are you using?
jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Fri May 02, 2014 10:35 am |
|
|
Further comments though, remember that scanf, is a multi character function. INT_RDA, implies _one_ character is waiting. You will hang code operation while the data is received to meet your scanf specification. Not good.
The example shows how to implement the buffering, using the new V5 buffer ability, and you should tell the RS232 setup to use the INT_RDA.
If your compiler is new enough, then I'd suspect one of the variables is not defined. Remember it wants the _address_ of the value you want to store.
Best Wishes |
|
|
roger_cris
Joined: 02 May 2014 Posts: 5
|
|
Posted: Fri May 02, 2014 10:57 am |
|
|
temtronic wrote: | Maybe a silly question but what version of the compiler are you using?
jay |
CCS MPLABx plug in V1.57. |
|
|
roger_cris
Joined: 02 May 2014 Posts: 5
|
|
Posted: Fri May 02, 2014 11:00 am |
|
|
Ttelmah wrote: | Further comments though, remember that scanf, is a multi character function. INT_RDA, implies _one_ character is waiting. You will hang code operation while the data is received to meet your scanf specification. Not good.
The example shows how to implement the buffering, using the new V5 buffer ability, and you should tell the RS232 setup to use the INT_RDA.
If your compiler is new enough, then I'd suspect one of the variables is not defined. Remember it wants the _address_ of the value you want to store.
Best Wishes |
I can't find online any information if the MPLABx plug in compiler supports that function.
Regarding the code in INT_RDA i will change it, because i believe it will not do the job TKU Ttelmah |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
Posted: Fri May 02, 2014 11:52 am |
|
|
scanf() is supported starting around CCS COMPILER version 5.012.
You are providing the MPLABX version which is not CCS software, it is by Microchip.
The CCS version is at the top of the .LST file generated by the compiler. _________________ Google and Forum Search are some of your best tools!!!! |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri May 02, 2014 2:18 pm |
|
|
Here is a list of ways to find the CCS compiler version:
1. Compile a test file, and look at the top of the .LST file, which will
be in your project folder. It will show the version. However, to get
the .LST file to be generated, the source file must compile with no errors.
2. Click on the Start button in Windows, then go to Programs, and then
find the entry for CCS, which will be called "PIC-C". Then click on the icon
for "Compiler Version". It will display a box which shows the compiler
version.
3. Open a Command Prompt window and go to c:\Program Files\Picc
and run this command line: CCSC.exe +v
This method should always work. |
|
|
roger_cris
Joined: 02 May 2014 Posts: 5
|
|
Posted: Fri May 02, 2014 2:43 pm |
|
|
PCM programmer wrote: | Here is a list of ways to find the CCS compiler version:
1. Compile a test file, and look at the top of the .LST file, which will
be in your project folder. It will show the version. However, to get
the .LST file to be generated, the source file must compile with no errors.
2. Click on the Start button in Windows, then go to Programs, and then
find the entry for CCS, which will be called "PIC-C". Then click on the icon
for "Compiler Version". It will display a box which shows the compiler
version.
3. Open a Command Prompt window and go to c:\Program Files\Picc
and run this command line: CCSC.exe +v
This method should always work. |
5.008, have to upgrade? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9243 Location: Greensville,Ontario
|
|
Posted: Fri May 02, 2014 2:53 pm |
|
|
yes, you'll have to upgrade
or
cut your own 'scan(....)' function
be aware that 5.008 was 'young' and had a few 'problems'...
hth
jay |
|
|
roger_cris
Joined: 02 May 2014 Posts: 5
|
|
Posted: Fri May 02, 2014 3:03 pm |
|
|
temtronic wrote: | yes, you'll have to upgrade
or
cut your own 'scan(....)' function
be aware that 5.008 was 'young' and had a few 'problems'...
hth
jay |
Tk U All for the support! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19538
|
|
Posted: Sat May 03, 2014 12:10 am |
|
|
As a comment though, some core parts of a scanf function have previously been published here.
Have a look at:
<http://www.ccsinfo.com/forum/viewtopic.php?t=20225>
This is a sscanf function, so in a real sense much better suited to receiving data. Use an interrupt driven serial buffer. Read the data into a string when a line feed is received, and use sscanf on this.
The comments on 5.008 definitely apply though.
Best Wishes |
|
|
|