It is currently 22 May 2019 06:10

All times are UTC + 1 hour




Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: 27 May 2009 13:25 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3778
Location: Nieuwpoort, Belgium
Added 30-5-2009: Mea Culpa. :oops::oops::oops:
The problem was caused by a very stupid error I made: I made a string too smal in my testcases, and this caused to overwrite a buffer holding pointers to procedures. Of course everything went wrong once the program tried to call these errorneous non existing routines...
Thanks Janni, for finding the cause of the problem, and Marko, Janni and Zoran for your neverlasting effort to find the cause.
Anyway, the good news is: it was my own stupid fault, and the compiler performed well!!


p.s. I knew this was one of the pitfalls (see http://users.edpnet.be/rosseel01/DRO/PIC/Pitfalls.htm) point 4, and still... :oops:

------- original description: ----------------

Hi, I discovered that manipulating INTCON stops my program. I can not find the line where INTCON is read in the listfile, but the code generated is different anyway. I use the P18F2620.

I wonder if the different assembled code can be the reason why my program stops working (I am not familiar with assembly...). The issue seems to be "boolean" related.

p.s. "RtosRunning" is a boolean.
p.s2: the line "INTCON := INTCON;" is of course a silly statement, it is only used here in this sample code to illustrate the issue.

1. NOT working code

Pascal:
  while RtosRunning do
  begin
    INTCON := INTCON;  // <--- cause of the problem
    I := 0;
    ...

Listfile shows:
;Rtos.mpas,111 ::                 while RtosRunning do
L__Rtos_Start10:
0x0878        0x0100              MOVLB       0
0x087A        0x53BD              MOVF        Rtos_RtosRunning, 1, 1
0x087C        0xB4D8              BTFSC       STATUS, 2
0x087E        0xD355              BRA         L__Rtos_Start11
;Rtos.mpas,122 ::                 I := 0;
0x0880        0x0101              MOVLB       1
0x0882        0x6B35              CLRF        Rtos_Start_I, 1


2. Working code

Pascal:
  while RtosRunning do
  begin
    //INTCON := INTCON;  // <--- cause of the problem
    I := 0;
    ...

Listfile shows:
;Rtos.mpas,111 ::                 while RtosRunning do
L__Rtos_Start10:
0x0872        0x527F              MOVF        Rtos_RtosRunning, 1
0x0874        0xB4D8              BTFSC       STATUS, 2
0x0876        0xD356              BRA         L__Rtos_Start11
;Rtos.mpas,122 ::                 I := 0;
0x0878        0x0101              MOVLB       1
0x087A        0x6B35              CLRF        Rtos_Start_I, 1


Further, when the statement "INTCON := INTCON;" is present, all code related to "RtosRunning" is compiled differently:

1. Line present (problem)
Pascal
  RtosRunning := false;

Listfile:
;Rtos.mpas,77 ::       RtosRunning := false;
0x059A   0x0100         MOVLB       0
0x059C   0x6BBD         CLRF        Rtos_RtosRunning, 1

Pascal
  RtosRunning := true;

Listfile:
;Rtos.mpas,108 ::       RtosRunning := true;
0x084A   0x0EFF         MOVLW       255
0x084C   0x0100         MOVLB       0
0x084E   0x6FBD         MOVWF       Rtos_RtosRunning, 1


2. Line absent (no problem)
Pascal
  RtosRunning := false;

ListFile:
;Rtos.mpas,77 ::       RtosRunning := false;
0x059A   0x6A7F         CLRF        Rtos_RtosRunning

Pascal
  RtosRunning := true;

Listfile:
;Rtos.mpas,108 ::       RtosRunning := true;
0x0846   0x0EFF         MOVLW       255
0x0848   0x6E7F         MOVWF       Rtos_RtosRunning

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Last edited by Dany on 16 Jun 2009 20:40, edited 9 times in total.

Top
 Profile  
 
 Post subject:
PostPosted: 27 May 2009 13:45 
Offline

Joined: 22 Apr 2005 17:40
Posts: 1984
Location: France 87
what is the point of showing asembly-fragments without any compilable source? One can allways guess and speculate but the differences in output are possibly not directly related to one line of code, the optimizer might have made different decisions afterwards, in order to solve the issue you best provide small example demonstrating the issue.

_________________
Au royaume des aveugles, les borgnes sont rois.


Top
 Profile  
 
 Post subject:
PostPosted: 27 May 2009 17:05 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3778
Location: Nieuwpoort, Belgium
Hi Jpc, you are right of couse.
I am trying to make a "minimal" project that shows the phenomenon, but I did not succeed in that (yet). The "minimal" project approaches the size of the actual project already. :cry:
In the minimal project I see some things that go wrong which I did not expect to go wrong, so I have some work to do.

The actual project (and now also the minimal one) uses something that I never used before (in mikroPascal): functionpointers. :evil:
So, you can imagine, it is not so simple...

Anyway, I suggest to freeze this thread/problem until I know more...
Thanks anyway! :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
PostPosted: 27 May 2009 17:27 
Offline

Joined: 18 Feb 2006 13:17
Posts: 5113
Dany wrote:
The issue seems to be "boolean" related.
No, I don't think so :) . There's obviously a difference in RAM organisation. Without the INTCON line, RtosRunning is placed in access bank, while in the other case it's not. Hence the difference in assembly.

Still, I do not see anything wrong in the pieces of code you've shown. The problem probably lies elsewhere, like jpc suggested. Let us know of new developments.


Top
 Profile  
 
 Post subject:
PostPosted: 27 May 2009 17:50 
Offline

Joined: 19 Sep 2006 12:57
Posts: 1868
Location: Romania, Arad City
Please talk with Zoran about this, I think this problem is fixed for the final release.

_________________
Best regards, Florin Andrei Medrea.

http://www.microelemente.ro/
http://www.microelemente.ro/produse-si-servicii/
http://www.microelemente.ro/custom-software/

mail : florin@microelemente.ro


Top
 Profile  
 
 Post subject:
PostPosted: 27 May 2009 18:51 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3778
Location: Nieuwpoort, Belgium
yo2lio wrote:
Please talk with Zoran about this, I think this problem is fixed for the final release.
Thanks, I will do so. :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
PostPosted: 27 May 2009 18:55 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3778
Location: Nieuwpoort, Belgium
janni wrote:
Dany wrote:
The issue seems to be "boolean" related.
No, I don't think so :) . There's obviously a difference in RAM organisation. Without the INTCON line, RtosRunning is placed in access bank, while in the other case it's not. Hence the difference in assembly.
It is a pity that I know so little about the bare MPU and the memory organisation (so I do not understand what you say... :oops:). Anyway, could the different place of "RtosRunning" be the reason that my software blocks?

janni wrote:
Still, I do not see anything wrong in the pieces of code you've shown. The problem probably lies elsewhere, like jpc suggested. Let us know of new developments.
Thanks. Ok I will keep you informed. In the mean time see also the post of Yo2Lio. I have also sent a PM to Zoran. :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
 Post subject:
PostPosted: 27 May 2009 19:30 
Offline

Joined: 22 Apr 2005 17:40
Posts: 1984
Location: France 87
we had another 5 posts on this , no example so far , please get out something substantial !

_________________
Au royaume des aveugles, les borgnes sont rois.


Top
 Profile  
 
 Post subject:
PostPosted: 28 May 2009 10:11 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3778
Location: Nieuwpoort, Belgium
Hi, there is news:

the problem does not occur when I use the "conversions" library from Janni/Yo2Lio: http://www.mikroe.com/forum/viewtopic.php?t=20128.:D

To my surprise the project worked today as desired, and the only difference between now and yesterday was the conversions library (from which I did only used the procedure "IntToStr").

Anyway, now I can reproduce the presence and absence of the problem.:D

To whom should I send my project code to make thorough investigation possible?

Thanks in advance! :D

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
 Post subject:
PostPosted: 28 May 2009 10:23 
Offline
mikroElektronika team
User avatar

Joined: 03 Aug 2004 12:59
Posts: 6608
Dany wrote:
To whom should I send my project code to make thorough investigation possible?

Please send it to me. Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: 28 May 2009 11:22 
Offline

Joined: 18 Jun 2008 11:43
Posts: 3778
Location: Nieuwpoort, Belgium
zristic wrote:
Dany wrote:
To whom should I send my project code to make thorough investigation possible?

Please send it to me. Thanks.
Ok, I will send it to you. Thanks! :D
... done

_________________
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)


Top
 Profile  
 
 Post subject:
PostPosted: 28 May 2009 14:50 
Offline

Joined: 18 Feb 2006 13:17
Posts: 5113
Dany wrote:
To whom should I send my project code to make thorough investigation possible?
I wouldn't mind getting it, as well :wink: . Next release of the compiler is coming any day now and it's a last moment to find problems and get them fixed.


Top
 Profile  
 
 Post subject:
PostPosted: 28 May 2009 15:12 
Offline
mikroElektronika team
User avatar

Joined: 03 Aug 2004 12:59
Posts: 6608
Sent. Thanks.


Top
 Profile  
 
PostPosted: 29 May 2009 04:33 
Offline

Joined: 17 Feb 2009 02:39
Posts: 272
Location: Colombia
I use in a program interrup and use intcon

And same time if i use the floattostr procedure, this afeect the intcon and the interrupt dont work.

I did the progarm en 1.4 pro and dont work, and later tralate the code a 8.01 and work perfect

But i believe que the conversion library have problem and affect the intocn register.

I want that mikropascal is the best ,this is possible between all.

My future web: http://alcidesramos.uuuq.com/


Top
 Profile  
 
PostPosted: 29 May 2009 11:22 
Offline
mikroElektronika team
User avatar

Joined: 03 Aug 2004 12:59
Posts: 6608
alcidesramos wrote:
I use in a program interrup and use intcon

And same time if i use the floattostr procedure, this afeect the intcon and the interrupt dont work

Please provide us an example of the code which fails. You can post it here or send it to zristic aatt mikroe.com.
Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


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 post attachments in this forum

Search for:
Jump to: