[Ok]v1.50: manipulating INTCON stops my program

Beta Testing discussion on mikroPascal PRO for PIC.
Author
Message
Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

[Ok]v1.50: manipulating INTCON stops my program

#1 Post by Dany » 27 May 2009 13:25

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:

Code: Select all

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

Code: Select all

;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:

Code: Select all

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

Code: Select all

;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

Code: Select all

  RtosRunning := false;
Listfile:

Code: Select all

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

Code: Select all

  RtosRunning := true;
Listfile:

Code: Select all

;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

Code: Select all

  RtosRunning := false;
ListFile:

Code: Select all

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

Code: Select all

  RtosRunning := true;
Listfile:

Code: Select all

;Rtos.mpas,108 :: 		RtosRunning := true;
0x0846	0x0EFF      	MOVLW       255
0x0848	0x6E7F      	MOVWF       Rtos_RtosRunning
Last edited by Dany on 16 Jun 2009 20:40, edited 9 times in total.
Kind regards, Dany.
Forget your perfect offering. There is a crack in everything, that's how the light gets in... (L. Cohen)
Remember when we were young? We shone like the sun. (David Gilmour)

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

#2 Post by jpc » 27 May 2009 13:45

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.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

#3 Post by Dany » 27 May 2009 17:05

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)
Remember when we were young? We shone like the sun. (David Gilmour)

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: [Hold]v1.50: manipulating INTCON stops my program

#4 Post by janni » 27 May 2009 17:27

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.

yo2lio
Posts: 1878
Joined: 19 Sep 2006 12:57
Location: Romania, Arad City
Contact:

#5 Post by yo2lio » 27 May 2009 17:50

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

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

#6 Post by Dany » 27 May 2009 18:51

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)
Remember when we were young? We shone like the sun. (David Gilmour)

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

Re: [Hold]v1.50: manipulating INTCON stops my program

#7 Post by Dany » 27 May 2009 18:55

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)
Remember when we were young? We shone like the sun. (David Gilmour)

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

#8 Post by jpc » 27 May 2009 19:30

we had another 5 posts on this , no example so far , please get out something substantial !
Au royaume des aveugles, les borgnes sont rois.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

#9 Post by Dany » 28 May 2009 10:11

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)
Remember when we were young? We shone like the sun. (David Gilmour)

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#10 Post by zristic » 28 May 2009 10:23

Dany wrote:To whom should I send my project code to make thorough investigation possible?
Please send it to me. Thanks.

Dany
Posts: 3854
Joined: 18 Jun 2008 11:43
Location: Nieuwpoort, Belgium
Contact:

#11 Post by Dany » 28 May 2009 11:22

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)
Remember when we were young? We shone like the sun. (David Gilmour)

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

#12 Post by janni » 28 May 2009 14:50

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.

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

#13 Post by zristic » 28 May 2009 15:12

Sent. Thanks.

alcidesramos
Posts: 272
Joined: 17 Feb 2009 02:39
Location: Colombia
Contact:

hello about intcon and conversion library

#14 Post by alcidesramos » 29 May 2009 04:33

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/

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: hello about intcon and conversion library

#15 Post by zristic » 29 May 2009 11:22

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.

Post Reply

Return to “mikroPascal PRO for PIC Beta Testing”