CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Please help me understand this STRANGE problem.

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
pumiddu



Joined: 07 Jan 2007
Posts: 3

View user's profile Send private message

Please help me understand this STRANGE problem.
PostPosted: Fri Aug 27, 2010 10:40 am     Reply with quote

Hello, first of all I would thank you anybody would help me to solve this issue.

I'm using CCS compiler version 4.094 for an application running on PIC16F886.
The application includes a menu, I made using pointers to function. I made an array of struct for each menu and submenus, where I put menu entry string and the relative pointer to function. The menu engine works fine, but I encountered a problem during the firmware updating. I saw a character of one menu entry string is different than that I wrote in the C code. I thought it was a compiler issue, but I found in the .lst file the compiled code is correct. I post you the part of the compiled code.


Code:
 .................... MenuItem TestMenu[3]={{"TEST DISP.", test_display}, {"TEST KEYS ",test_keys}, {"RETURN    ",return_mainmenu}};
193B:  MOVLW  54
193C:  BCF    03.5
193D:  BSF    03.6
193E:  MOVWF  10
193F:  MOVLW  45
1940:  MOVWF  11
1941:  MOVLW  53
1942:  MOVWF  12
1943:  MOVLW  54
1944:  MOVWF  13
1945:  MOVLW  20
1946:  MOVWF  14
1947:  MOVLW  44
1948:  MOVWF  15
1949:  MOVLW  49
194A:  MOVWF  16
194B:  MOVLW  53
194C:  MOVWF  17
194D:  MOVLW  50
194E:  MOVWF  18
194F:  MOVLW  2E
1950:  MOVWF  19
1951:  CLRF   1A
1952:  MOVLW  15
1953:  MOVWF  1C
1954:  MOVLW  A5
1955:  MOVWF  1B
1956:  MOVLW  54
1957:  MOVWF  1D
1958:  MOVLW  45
1959:  MOVWF  1E
195A:  MOVLW  53
195B:  MOVWF  1F
195C:  MOVLW  54
195D:  MOVWF  20
195E:  MOVLW  20
195F:  MOVWF  21
1960:  MOVLW  4B
1961:  MOVWF  22
1962:  MOVLW  45
1963:  MOVWF  23
1964:  MOVLW  59
1965:  MOVWF  24
1966:  MOVLW  53
1967:  MOVWF  25
1968:  MOVLW  20
1969:  MOVWF  26
196A:  CLRF   27
196B:  MOVLW  16
196C:  MOVWF  29
196D:  MOVLW  2E
196E:  MOVWF  28
196F:  MOVLW  52
1970:  MOVWF  2A
1971:  MOVLW  45
1972:  MOVWF  2B
1973:  MOVLW  54
1974:  MOVWF  2C
1975:  MOVLW  55
1976:  MOVWF  2D
1977:  MOVLW  52
1978:  MOVWF  2E
1979:  MOVLW  4E
197A:  MOVWF  2F
197B:  MOVLW  20
197C:  MOVWF  30
197D:  MOVWF  31
197E:  MOVWF  32
197F:  MOVWF  33
1980:  CLRF   34
1981:  MOVLW  14
1982:  MOVWF  36
1983:  MOVLW  C9
1984:  MOVWF  35
.................... 



Line 1949 would load W register with value 0x49 = 'I' character, but I found 0xFF in file register instead.

My questions are: is it assembler or programming issue ? How can I understand what's happening?

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 27, 2010 10:53 am     Reply with quote

Post a short test program that shows the problem. It must be compilable.
Here are some examples of test programs for function pointers in structures:
http://www.ccsinfo.com/forum/viewtopic.php?t=33458
http://www.ccsinfo.com/forum/viewtopic.php?t=31637
http://www.ccsinfo.com/forum/viewtopic.php?t=35500
Strip your program down so it's the minimum size needed to show the
problem (no CCS Wizard code). It should have the #include, #fuses,
#use delay(), and main() in it, and compile with no errors.

In your program, indicate with a comment, the line where you see the
problem. Explain what you're doing to see the problem (ie., printf,
or using debugger with a watch window, breakpoint on the line, etc.)
pumiddu



Joined: 07 Jan 2007
Posts: 3

View user's profile Send private message

PostPosted: Fri Aug 27, 2010 11:05 am     Reply with quote

Thank you for your prompt reply "PCM Programmer",
as I wrote and you can check in the first post the compiled code It's correct.
The compiled code reflect the C instruction shown.
It seem an assembler issue when generating the .hex file or during programming.
If you however think it's a compile issue, please write me again and I will make a short C list version.
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Fri Aug 27, 2010 11:47 am     Reply with quote

pumiddu wrote:

as I wrote and you can check in the first post the compiled code It's correct.


It's not complete.

You need the proper header info which normally would include
the PIC's .H file, the fuses statements and such all the way to and through main().

Your post does not include this.

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Aug 27, 2010 12:00 pm     Reply with quote

Quote:
as I wrote and you can check in the first post the compiled code It's correct.

>>
Quote:
Post a short test program that shows the problem. It must be compilable.

How could we locate the problem without a test code? The test should also include
your method to display the error. E.g. printf() or whatsoever.
pumiddu



Joined: 07 Jan 2007
Posts: 3

View user's profile Send private message

PostPosted: Fri Aug 27, 2010 12:25 pm     Reply with quote

Thank you all for your attention,
Please find below some of the C code I wrote, that as I told it works fine.
It's a code extract, since it's long and could cause confusing.

Code:
#include <16F886.h>
#device *=16
#device adc=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                  //Internal RC Osc, no CLKOUT
#FUSES PUT                      //Power Up Timer
#FUSES MCLR                     //Master Clear pin enabled
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOCPD                    //No EE protection
#FUSES NOBROWNOUT               //Reset when brownout detected
#FUSES NOIESO                   //Internal External Switch Over mode enabled
#FUSES NOFCMEN                  //Fail-safe clock monitor enabled
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NODEBUG                  //Debug mode for use with ICD
#FUSES BORV40                   //Brownout reset at 4.0V
#FUSES NOWRT                    //Program memory not write protected

#use delay(clock=8000000)
#use rs232(uart1, baud=9600, parity=N,   bits=8, ERRORS, DISABLE_INTS) //
#use i2c(master, sda=PIN_A3, scl=PIN_A2, Fast)
#use spi(MASTER, FORCE_HW, BITS=8, stream=SPISTREAM)

#zero_ram

typedef void (*pFunc)(void);     //pointer to function

typedef struct {      //menu struct
   CHAR name[11];
   pFunc ptrFunc;
} MenuItem;

//menu and submenu

MenuItem *pMenu;         
MenuItem MainMenu[3]={{"WIRELESS  ", enter_submenu}, {"TEST      ",enter_submenu}, {"EXIT      ", exit_mainmenu}};
MenuItem WirelessMenu[3]={{"REG. RETE ", registration_network}, {"N. CONVOGL",show_conveyerid}, {"RETURN    ",return_mainmenu}};                                    
MenuItem TestMenu[3]={{"TEST DISP.", test_display}, {"TEST KEYS ",test_keys}, {"RETURN    ",return_mainmenu}};


void main()
{
      
   // in my long list program, I use the following instruction to set the pointer to one of the 3 menus above
   // for example here to test menu.
   pMenu=&TestMenu[0];

   //the following instruction one of the function of the menu pointed by pMenu
   pMenu[menuentrynumber].ptrFunc();
}


The problem is just when I read TestMenu[0].name value. The compiled code would give "TEST DISP.", and you can also check it in the in my first post it's. While I have in my LCD a 0xFF value in the "I" position, which would be 0x49 in ASCII code.
Hope you can focus the problem well now.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Aug 27, 2010 12:46 pm     Reply with quote

Quote:
Executing: "C:\Program Files\PICC\Ccsc.exe" +FM "pcm_test.c" +DF +LN -T -A +M -Z +Y=9 +EA -EW
*** Error 12 "pcm_test.c" Line 36(38,51): Undefined identifier enter_submenu
*** Error 43 "pcm_test.c" Line 36(52,53): Expecting a declaration
*** Error 43 "pcm_test.c" Line 36(54,55): Expecting a declaration
*** Error 43 "pcm_test.c" Line 36(67,68): Expecting a declaration
*** Error 43 "pcm_test.c" Line 36(67,68): Expecting a declaration
*** Error 48 "pcm_test.c" Line 36(68,81): Expecting a (
.
.
.
40 Errors, 0 Warnings.
Skipping link step. Not all sources built successfully.
BUILD FAILED: Fri Aug 27 11:47:24 2010

Hope you can focus the problem well now.

No. The program doesn't compile. You were asked twice to do this
and you didn't do it. I'm giving up on this thread. I won't be back.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group