![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
slavka012
Joined: 10 Feb 2012 Posts: 28
|
PIC24FJ64GA306 startup problem |
Posted: Fri Dec 11, 2020 2:56 pm |
|
|
I have an application that works fine when I used compiler V5.075. Recently I have switched to V5.093, and the program no longer works. As far as I can tell it never reaches the main(). I mean MY main. In the beginning of the main() I see a compiler generated code that initializes global variables. On the V5.075 it is a linear piece of code that simple loads a value into W and then stores into the corresponding memory area. On the V.5.093 it is more complex. I see the data area is defined with values and addresses of the variables and there is a code that iterates through the data. That piece of code is getting stuck and the actual main() never executes.
Code: | void main() {
output_drive(PIN_B1);
while(1) {
output_low(PIN_B1);
output_high(PIN_B1);
restart_wdt();
}
} |
Once again, entire application works with the older compiler.
Please let me know if there is a way to switch to the old way of data initialization, or if this was already fixed in later revisions. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19363
|
|
Posted: Sat Dec 12, 2020 3:20 am |
|
|
Have just built a minimum project, with you published 'main', using
5.075, and 5.093, and the initialisation is identical.
Now I suspect two things. First you are using restart_wdt, which suggests
you have the watchdog setup to enable in hardware, possibly with quite a
short period?.
Possibly you use #ZERO_RAM?
The only 'loop' initialisation, is if you have zero_ram enabled. Even with this
though the initialisation is identical:
Code: |
//5.075
.................... void main() {
*
0200: MOV #2780,W15
0202: MOV #27FF,W0
0204: MOV W0,20
0206: NOP
0208: BSET.B 81.7
020A: MOV #0,W0
020C: MOV W0,384
020E: MOV #FFFF,W0
0210: MOV W0,386
0212: MOV #800,W0
0214: MOV #FFE,W1
0216: REPEAT W1
0218: CLR [W0++]
021A: CLR 744
021C: MOV.B #5,W0L
021E: MOV.B W0L,588
0220: CLR 4E2
0222: CLR 4E6
0224: CLR 4E8
0226: CLR 4EC
|
Code: |
//5.093
.................... void main() {
*
0200: MOV #2780,W15
0202: MOV #27FF,W0
0204: MOV W0,20
0206: NOP
0208: BSET.B 81.7
020A: MOV #0,W0
020C: MOV W0,384
020E: MOV #FFFF,W0
0210: MOV W0,386
0212: MOV #800,W0
0214: MOV #FFE,W1
0216: REPEAT W1
0218: CLR [W0++]
021A: CLR 744
021C: MOV.B #5,W0L
021E: MOV.B W0L,588
0220: CLR 4E2
0222: CLR 4E6
0224: CLR 4E8
0226: CLR 4EC
|
You must have some peripheral setups (#use). These may differ, usually
to fix problems that have been found. Post these. |
|
![](templates/subSilver/images/spacer.gif) |
slavka012
Joined: 10 Feb 2012 Posts: 28
|
|
Posted: Sun Dec 13, 2020 2:44 pm |
|
|
Ttelmah wrote: | Have just built a minimum project, with you published 'main', using
5.075, and 5.093, and the initialization is identical.
|
I imagine that's because there are no global variables to initialize in your code. Try adding a large array initialized with a bunch of random numbers.
Quote: |
Now I suspect two things. First you are using restart_wdt, which suggests
you have the watchdog setup to enable in hardware, possibly with quite a
short period?.
|
Of course not. First of all, there is no WDT period so short that even init of globals can't complete, and second, my entire application works on 5.075.
Quote: |
You must have some peripheral setups (#use). These may differ, usually
to fix problems that have been found. Post these. |
I have RS232 and maybe something else but that has nothing to do with the problem. Try to understand that I spent enough time analyzing it to know exactly what is broken. There is no need to guess.
Here is the portion of the main just before my code starts.
Code: | .................... void main() {
16B4: MOV #2780,W15
16B6: MOV #27FF,W0
16B8: MOV W0,20
16BA: NOP
16BC: MOV #4444,W0
16BE: MOV W0,A6
16C0: MOV #4444,W0
16C2: MOV W0,B0
16C4: BSET.B 81.7
16C6: MOV #0,W0
16C8: MOV W0,384
16CA: MOV #FFFF,W0
16CC: MOV W0,386
16CE: DISI #6
16D0: MOV #742,W1
16D2: MOV #46,W2
16D4: MOV #57,W3
16D6: MOV.B W2L,[W1]
16D8: MOV.B W3L,[W1]
16DA: BCLR.B 742.6
16DC: MOV #12,W0
16DE: MOV W0,6C2
16E0: MOV #13,W0
16E2: MOV W0,6D6
16E4: DISI #6
16E6: MOV #742,W1
16E8: MOV #46,W2
16EA: MOV #57,W3
16EC: MOV.B W2L,[W1]
16EE: MOV.B W3L,[W1]
16F0: BSET.B 742.6
16F2: BCLR.B 2C8.0
16F4: BCLR.B 2CC.0
16F6: BCLR.B 807.0
16F8: CLR 80C
16FA: CLR 80E
16FC: CLR 810
16FE: BCLR.B 807.1
1700: BCLR.B 807.2
1702: BCLR.B 807.3
1704: BCLR.B 807.4
1706: BCLR.B 807.5
1708: BSET.B 807.6
170A: BCLR.B 807.7
170C: BCLR.B 81B.0
170E: CLR 81C
1710: CLR 81E
1712: CLR.B 823
1714: CLR.B 83F
1716: MOV.B #4,W0L
1718: MOV.B W0L,860
171A: MOV.B #2,W0L
171C: MOV.B W0L,861
171E: MOV.B #1,W0L
1720: MOV.B W0L,862
1722: CLR.B 863
1724: BCLR.B 81B.1
1726: CLR 86C
1728: CLR.B 805
172A: CLR.B 806
172C: BCLR.B 81B.2
172E: BCLR.B 81B.3
1730: BCLR.B 81B.4
1732: CLR.B 89A
1734: CLR.B 89C
1736: CLR.B 8A6
1738: BCLR.B 81B.5
173A: BCLR.B 81B.6
173C: BCLR.B 81B.7
173E: BCLR.B 8A8.0
1740: CLR 8AA
1742: CLR 8AC
1744: BCLR.B 8A8.1
1746: BCLR.B 8A8.2
1748: CLR.B 8B1
174A: CLR 8B4
174C: BCLR.B 8A8.7
174E: BSET.B 8B6.0
1750: CLR.B 8B7
1752: CLR.B 8B8
1754: MOV.B #5,W0L
1756: MOV.B W0L,588
1758: CLR 4E2
175A: CLR 4E6
175C: CLR 4E8
175E: CLR 4EC
1760: BCLR.B 8A8.3
1762: BCLR.B 8A8.4
1764: BCLR.B 8A8.5
1766: BCLR.B 8A8.6
1768: BCLR.B 8B6.1
176A: BRA 17CA
176C: DATA C0,09,08
176E: DATA 12,00,80
1770: DATA 03,08,20
1772: DATA 00,00,00
1774: DATA 80,1B,08
1776: DATA 24,00,00
1778: DATA 00,B2,AC
177A: DATA AE,B0,B8
177C: DATA 00,D4,D3
177E: DATA D7,D1,B3
1780: DATA AD,AF,B1
1782: DATA 04,00,D5
1784: DATA D2,D0,B4
1786: DATA B5,B6,B7
1788: DATA 00,C0,05
178A: DATA 08,67,00
178C: DATA C0,20,08
178E: DATA 6E,FF,40
1790: DATA 08,00,00
1792: DATA 04,FF,FF
1794: DATA 07,8F,80
1796: DATA 01,08,A7
1798: DATA 00,80,01
179A: DATA 08,A9,00
179C: DATA 80,03,08
179E: DATA AE,00,00
17A0: DATA 00,80,02
17A2: DATA 08,B2,00
17A4: DATA 00,80,02
17A6: DATA 08,B9,00
17A8: DATA 00,80,02
17AA: DATA 08,BC,00
17AC: DATA 00,00,00
17AE: INC W2,W2
17B0: CP W2,#1
17B2: BRA NZ,17BC
17B4: TBLRDL [W1],W3
17B6: TBLRDH [W1++],W4
17B8: MOV.B 6,W0L
17BA: RETURN
17BC: CP W2,#2
17BE: BRA NZ,17C4
17C0: MOV.B 7,W0L
17C2: RETURN
17C4: MOV.B 8,W0L
17C6: CLR W2
17C8: RETURN
17CA: MOV #0,W6
17CC: MOV #0,W0
17CE: MOV W0,54
17D0: MOV #176C,W0
17D2: MOV W0,W1
17D4: CLR W2
17D6: CALL 17AE
*
17DA: MOV.B W0L,B
17DC: CALL 17AE
*
17E0: MOV.B W0L,A
17E2: CP0 W5
17E4: BRA Z,1818
17E6: BTSS W5.F
17E8: BRA 17F8
17EA: CALL 17AE
*
17EE: MOV.B W0L,D
17F0: CALL 17AE
*
17F4: MOV.B W0L,C
17F6: BCLR W5.F
17F8: BTSS W5.E
17FA: BRA 180C
17FC: BCLR W5.E
17FE: DEC W5,W5
1800: CALL 17AE
*
1804: MOV.B W0L,W7L
1806: REPEAT W5
1808: MOV.B W7L,[W6++]
180A: BRA 17D6
180C: CALL 17AE
*
1810: MOV.B W0L,[W6++]
1812: DEC W5,W5
1814: BRA NZ,180C
1816: BRA 17D6
|
|
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19363
|
|
Posted: Mon Dec 14, 2020 1:32 am |
|
|
I've just built one with a 256 element array. The initialisation is identical between 5.075, and 5.093. Same data statements and loop to load it.
It is something specific you are doing, that is making the initialisation
differ. You need to work out what it is.
Are you sure you are comparing with 5.075?. there were changes to the data
initialisation a while before this. |
|
![](templates/subSilver/images/spacer.gif) |
slavka012
Joined: 10 Feb 2012 Posts: 28
|
|
Posted: Mon Dec 14, 2020 6:51 am |
|
|
Ttelmah wrote: | I've just built one with a 256 element array. The initialisation is identical between 5.075, and 5.093. Same data statements and loop to load it. | Obviously you did not fill it with random values like I told you to do. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19363
|
|
Posted: Mon Dec 14, 2020 7:16 am |
|
|
If you mean you are loading it with values using rand, then this is not done
during initialization. It is run time code. You can't load using a function
as part of the initialization.
The initialisation code you show just loads the data values from the data
statements into an array in RAM. |
|
![](templates/subSilver/images/spacer.gif) |
slavka012
Joined: 10 Feb 2012 Posts: 28
|
|
Posted: Mon Dec 14, 2020 7:52 am |
|
|
Ttelmah wrote: | If you mean you are loading it with values using rand, then this is not done
during initialization. It is run time code. You can't load using a function
as part of the initialization.
The initialisation code you show just loads the data values from the data
statements into an array in RAM. |
I mean something like that.
Code: | unsigned int8 Keys[3][10] = { // Keys with display using
{13, 51, 92, 60, 95, 85, 16, 100, 27, 77},
{10, 35, 42, 69, 16, 75, 9, 51, 90, 80},
{34, 85, 23, 48, 45, 16, 90, 75, 18, 65}
};
|
Why can't you accept what I'm saying at face value instead of coming up with theories how I'm doing something stupid and lecturing me on the basics of C programming. Quote: |
Are you sure you are comparing with 5.075? | Like, really. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19363
|
|
Posted: Mon Dec 14, 2020 8:02 am |
|
|
You are misunderstanding what I am saying.
I am not saying 'you are doing something stupid'. I am saying you are doing
something _different_ to what you describe.
The point is that if I compile exactly what you describe, there is no difference
at all between the initialisation code of the two compilers. So you have to be
doing something else beyond what you are describing to make the difference
occur. I set my test array up as a 256 element array, and the initialisation
is identical.
Now looking at your code, you are initialising I think perhaps seven arrays.
Post your real setup code.
Unless we can reproduce the behaviour, we can't know what is actually
happening. |
|
![](templates/subSilver/images/spacer.gif) |
slavka012
Joined: 10 Feb 2012 Posts: 28
|
|
Posted: Mon Dec 14, 2020 12:11 pm |
|
|
I did a bit more digging. Turned out it is WDT after all. On the 5.075 initialization code finishes up in 107mS (at 31KHz clock) and on 5.093 it takes over 120mS. WDT should nominally be 124mS, but somehow expires sooner. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah
Joined: 11 Mar 2010 Posts: 19363
|
|
Posted: Mon Dec 14, 2020 12:16 pm |
|
|
Some of the watchdog timers are _very_ inaccurate. On some chips they can
vary by over 50%!... |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|