|
|
View previous topic :: View next topic |
Author |
Message |
cparsons
Joined: 09 Jan 2008 Posts: 5
|
Watchdog reset, effect on I/O pin & ZERO_FILL |
Posted: Fri Jun 13, 2008 9:19 am |
|
|
compiler version: PCWH V4.070
I'm using one of the port D PIC18F4580 pins to control the active-low reset line of another peripheral.
In the case that the PIC resets due to a watchdog timeout I don't want the other peripheral also being reset - I'd like the pin to stay high.
The details of the PIC register values after a soft reset seem to indicate the Port D pins will be unchanged.
If I look at the pin with scope during a watchdog reset I see the pin voltage dip down to 1.9V over a period of 200us before going back up to the 3.3V, the high voltage.
If I create a much smaller program that configures a few registers then causes a watchdog reset then the voltage dip is of the order of a few microvolts over 15us.
If I compare the two .lst files I see that the larger program has about 500 CLRF instructions before the main() function instructions, presumably clearing memory and registers. The smaller program uses much less RAM so only has a couple of CLRF instructions before main().
I've read the documentation, and see the #ZERO_FILL compiler directive. I can't find anywhere in my code where I have included this directive, nor can I find an option for it in the IDE.
- Can anyone see why the CLRF instructions would have a bearing on the pin during a reset?
- If not, are there any other factors that influence the voltage on the pin through a reset?
- Is ZERO_FILL enabled by default on some versions of the compiler? If so, is there a way to turn it off?
Thank you
Chris Parsons
Here is the first instructions of the short program with the very ouput pin voltage dip:
Code: |
CCS PCH C Compiler, Version 4.070, 41847 13-Jun-08 14:31
Filename: ResetPinTest.lst
ROM used: 490 bytes (1%)
Largest free fragment is 32278
RAM used: 10 (1%) at main() level
13 (1%) worst case
Stack: 1 locations
*
0000: GOTO 00D4
<---snip--->
.................... #use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
....................
....................
.................... #FUSES WDT512 //Watch Dog Timer uses 1:256 Postscale
.................... #FUSES EC_IO //External clock
.................... #FUSES NOPROTECT //Code not protected from reading
.................... #FUSES BROWNOUT //Reset when brownout detected
.................... #FUSES BORV28 //Brownout reset at 2.8V
.................... #FUSES NOPUT //No Power Up Timer
.................... #FUSES NOCPD //No EE protection
.................... #FUSES STVREN //Stack full/underflow will cause reset
.................... #FUSES NODEBUG //Debug mode for use with ICD
.................... #FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
.................... #FUSES NOWRT //Program memory not write protected
.................... #FUSES NOWRTD //Data EEPROM not write protected
.................... #FUSES NOIESO //Internal External Switch Over mode disabled
.................... #FUSES NOFCMEN //Fail-safe clock monitor disabled
.................... #FUSES PBADEN //PORTB pins are configured as analog input channels on RESET
.................... #FUSES BBSIZ2K //2K words Boot Block size
.................... #FUSES NOWRTC //configuration not registers write protected
.................... #FUSES NOWRTB //Boot block not write protected
.................... #FUSES NOEBTR //Memory not protected from table reads
.................... #FUSES NOEBTRB //Boot block not protected from table reads
.................... #FUSES NOCPB //No Boot Block code protection
.................... #FUSES LPT1OSC //Timer1 configured for low-power operation
.................... #FUSES MCLR //Master Clear pin enabled
.................... #FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
....................
.................... #bit RCON_POR = 0x0FD0.1
.................... #define PIN_PPC750FL_HARD_RESET (PIN_D7)
.................... void main()
.................... {
*
00D4: CLRF FF8
00D6: BCF FD0.7
00D8: CLRF FEA
00DA: CLRF FE9
00DC: BCF FB8.3
00DE: MOVLW 17
00E0: MOVWF FAF
00E2: MOVLW A2
00E4: MOVWF FAC
00E6: MOVLW 90
00E8: MOVWF FAB
00EA: MOVF FC1,W
00EC: ANDLW C0
00EE: IORLW 0F
00F0: MOVWF FC1
00F2: MOVLW 07
00F4: MOVWF FB4
00F6: CLRF 05
.................... long int count;
....................
.................... setup_wdt(WDT_ON);
00F8: BSF FD1.0
.................... if (RCON_POR == 0)
00FA: BTFSC FD0.1
00FC: BRA 0102
.................... hardReset = 1;
00FE: MOVLW 01
|
and this is the equivalent code for the normal program
Code: |
CCS PCH C Compiler, Version 4.070, 41847 13-Jun-08 14:36
Filename: PMN_main.lst
ROM used: 18144 bytes (55%)
Largest free fragment is 14620
RAM used: 589 (38%) at main() level
663 (43%) worst case
Stack: 7 worst case (5 in main + 2 for interrupts)
*
0000: GOTO 40DA
<---snip - fuse configuration should be the same as above --->
....................
.................... void main ()
.................... {
*
40DA: CLRF FF8
40DC: BCF FD0.7
40DE: BSF 0D.7
40E0: CLRF FEA
40E2: CLRF FE9
40E4: BCF FB8.3
40E6: MOVLW 17
40E8: MOVWF FAF
40EA: MOVLW A2
40EC: MOVWF FAC
40EE: MOVLW 90
40F0: MOVWF FAB
40F2: MOVF FC1,W
40F4: ANDLW C0
40F6: IORLW 0F
40F8: MOVWF FC1
40FA: MOVLW 07
40FC: MOVWF FB4
40FE: MOVLW 40
4100: MOVWF 2B
4102: MOVLW 42
4104: MOVWF 2C
4106: MOVLW 0F
4108: MOVWF 2D
410A: CLRF 2E
410C: CLRF 33
410E: CLRF 34
4110: CLRF 35
4112: CLRF 36
4114: CLRF 37
4116: CLRF 38
4118: CLRF 39
411A: CLRF 3A
411C: CLRF 3B
411E: CLRF 3C
4120: CLRF 3D
4122: CLRF 3E
4124: CLRF 3F
4126: CLRF 40
4128: CLRF 41
412A: CLRF 42
412C: CLRF 43
412E: CLRF 44
4130: CLRF 45
4132: CLRF 46
4134: CLRF 47
4136: CLRF 48
4138: CLRF 49
413A: CLRF 4A
413C: CLRF 4B
413E: CLRF 4C
4140: CLRF 4D
4142: CLRF 4E
4144: CLRF 4F
4146: CLRF 50
4148: CLRF 51
414A: CLRF 52
414C: CLRF 53
414E: CLRF 54
4150: CLRF 55
4152: CLRF 56
4154: CLRF 57
4156: CLRF 58
4158: CLRF 59
415A: CLRF 5A
415C: CLRF 5B
415E: CLRF 5C
4160: CLRF 5D
4162: CLRF 5E
4164: CLRF 5F
4166: CLRF x60
4168: CLRF x61
416A: CLRF x62
416C: CLRF x63
416E: CLRF x64
4170: CLRF x65
4172: CLRF x66
4174: CLRF x67
4176: CLRF x68
4178: CLRF x69
417A: CLRF x6A
417C: CLRF x6B
417E: CLRF x6C
4180: CLRF x6D
4182: CLRF x6E
4184: CLRF x6F
4186: CLRF x70
4188: CLRF x71
418A: CLRF x72
418C: CLRF x73
418E: CLRF x74
4190: CLRF x75
4192: CLRF x76
4194: CLRF x77
4196: CLRF x78
4198: CLRF x79
419A: CLRF x7A
419C: CLRF x7B
419E: CLRF x7C
41A0: CLRF x7D
41A2: CLRF x7E
41A4: CLRF x7F
41A6: CLRF x80
41A8: CLRF x81
41AA: CLRF x82
41AC: CLRF x83
41AE: CLRF x84
41B0: CLRF x85
41B2: CLRF x86
41B4: CLRF x87
41B6: CLRF x88
41B8: CLRF x89
41BA: CLRF x8A
41BC: CLRF x8B
41BE: CLRF x8C
41C0: CLRF x8D
41C2: CLRF x8E
41C4: CLRF x8F
41C6: CLRF x90
41C8: CLRF x91
41CA: CLRF x92
41CC: CLRF x93
41CE: CLRF x94
41D0: CLRF x95
41D2: CLRF x96
41D4: CLRF x97
41D6: CLRF x98
41D8: CLRF x99
41DA: CLRF x9A
41DC: CLRF x9B
41DE: CLRF x9C
41E0: CLRF x9D
41E2: CLRF x9E
41E4: CLRF x9F
41E6: CLRF xA0
41E8: CLRF xA1
41EA: CLRF xA2
41EC: CLRF xA3
41EE: CLRF xA4
41F0: CLRF xA5
41F2: CLRF xA6
41F4: CLRF xA7
41F6: CLRF xA8
41F8: CLRF xA9
41FA: CLRF xAA
41FC: CLRF xAB
41FE: CLRF xAC
4200: CLRF xAD
4202: CLRF xAE
4204: CLRF xAF
4206: CLRF xB0
4208: CLRF xB1
420A: CLRF xB2
420C: CLRF xB3
420E: CLRF xB4
4210: CLRF xB5
4212: CLRF xB6
4214: CLRF xB7
4216: CLRF xB8
4218: CLRF xB9
421A: CLRF xBA
421C: CLRF xBB
421E: CLRF xBC
4220: CLRF xBD
4222: CLRF xBE
4224: CLRF xBF
4226: CLRF xC0
4228: CLRF xC1
422A: CLRF xC2
422C: CLRF xC3
422E: CLRF xC4
4230: CLRF xC5
4232: CLRF xC6
4234: CLRF xC7
4236: CLRF xC8
4238: CLRF xC9
423A: CLRF xCA
423C: CLRF xCB
423E: CLRF xCC
4240: CLRF xCD
4242: CLRF xCE
4244: CLRF xCF
4246: CLRF xD0
4248: CLRF xD1
424A: CLRF xD2
424C: CLRF xD3
424E: CLRF xD4
4250: CLRF xD5
4252: CLRF xD6
4254: CLRF xD7
4256: CLRF xD8
4258: CLRF xD9
425A: CLRF xDA
425C: CLRF xDB
425E: CLRF xDC
4260: CLRF xDD
4262: CLRF xDE
4264: CLRF xDF
4266: CLRF xE0
4268: CLRF xE1
426A: CLRF xE2
426C: CLRF xE3
426E: CLRF xE4
4270: CLRF xE5
4272: CLRF xE6
4274: CLRF xE7
4276: CLRF xE8
4278: CLRF xE9
427A: CLRF xEA
427C: CLRF xEB
427E: CLRF xEC
4280: CLRF xED
4282: CLRF xEE
4284: CLRF xEF
4286: CLRF xF0
4288: CLRF xF1
428A: CLRF xF2
428C: CLRF xF3
428E: CLRF xF4
4290: CLRF xF5
4292: CLRF xF6
4294: CLRF xF7
4296: CLRF xF8
4298: CLRF xF9
429A: CLRF xFA
429C: CLRF xFB
429E: CLRF xFC
42A0: CLRF xFD
42A2: CLRF xFE
42A4: CLRF xFF
42A6: MOVLB 1
42A8: CLRF x00
42AA: CLRF x01
42AC: CLRF x02
42AE: CLRF x03
42B0: CLRF x04
42B2: CLRF x05
42B4: CLRF x06
42B6: CLRF x07
42B8: CLRF x08
42BA: CLRF x09
42BC: CLRF x0A
42BE: CLRF x0B
42C0: CLRF x0C
42C2: CLRF x0D
42C4: CLRF x0E
42C6: CLRF x0F
42C8: CLRF x10
42CA: CLRF x11
42CC: CLRF x12
42CE: CLRF x13
42D0: CLRF x14
42D2: CLRF x15
42D4: CLRF x16
42D6: CLRF x17
42D8: CLRF x18
42DA: CLRF x19
42DC: CLRF x1A
42DE: CLRF x1B
42E0: CLRF x1C
42E2: CLRF x1D
42E4: CLRF x1E
42E6: CLRF x1F
42E8: CLRF x20
42EA: CLRF x21
42EC: CLRF x22
42EE: CLRF x23
42F0: CLRF x24
42F2: CLRF x25
42F4: CLRF x26
42F6: CLRF x27
42F8: CLRF x28
42FA: CLRF x29
42FC: CLRF x2A
42FE: CLRF x2B
4300: CLRF x2C
4302: CLRF x2D
4304: CLRF x2E
4306: CLRF x2F
4308: CLRF x30
430A: CLRF x31
430C: CLRF x32
430E: CLRF x33
4310: CLRF x34
4312: CLRF x35
4314: CLRF x36
4316: CLRF x37
4318: CLRF x38
431A: CLRF x39
431C: CLRF x3A
431E: CLRF x3B
4320: CLRF x3C
4322: CLRF x3D
4324: CLRF x3E
4326: CLRF x3F
4328: CLRF x40
432A: CLRF x41
432C: CLRF x42
432E: CLRF x43
4330: CLRF x44
4332: CLRF x45
4334: CLRF x46
4336: CLRF x47
4338: CLRF x48
433A: CLRF x49
433C: CLRF x4A
433E: CLRF x4B
4340: CLRF x4C
4342: CLRF x4D
4344: CLRF x4E
4346: CLRF x4F
4348: CLRF x50
434A: CLRF x51
434C: CLRF x52
434E: CLRF x53
4350: CLRF x54
4352: CLRF x55
4354: CLRF x56
4356: CLRF x57
4358: CLRF x58
435A: CLRF x59
435C: CLRF x5A
435E: CLRF x5B
4360: CLRF x5C
4362: CLRF x5D
4364: CLRF x5E
4366: CLRF x5F
4368: CLRF x60
436A: CLRF x61
436C: CLRF x62
436E: CLRF x63
4370: CLRF x64
4372: CLRF x65
4374: CLRF x66
4376: CLRF x67
4378: CLRF x68
437A: CLRF x69
437C: CLRF x6A
437E: CLRF x6B
4380: CLRF x6C
4382: CLRF x6D
4384: CLRF x6E
4386: CLRF x6F
4388: CLRF x70
438A: CLRF x71
438C: CLRF x72
438E: CLRF x73
4390: CLRF x74
4392: CLRF x75
4394: CLRF x76
4396: CLRF x77
4398: CLRF x78
439A: CLRF x79
439C: CLRF x7A
439E: CLRF x7B
43A0: CLRF x7C
43A2: CLRF x7D
43A4: CLRF x7E
43A6: CLRF x7F
43A8: CLRF x80
43AA: CLRF x81
43AC: CLRF x82
43AE: CLRF x83
43B0: CLRF x84
43B2: CLRF x85
43B4: CLRF x86
43B6: CLRF x87
43B8: CLRF x88
43BA: CLRF x89
43BC: CLRF x8A
43BE: CLRF x8B
43C0: CLRF x8C
43C2: CLRF x8D
43C4: CLRF x8E
43C6: CLRF x8F
43C8: CLRF x90
43CA: CLRF x91
43CC: CLRF x92
43CE: CLRF x93
43D0: CLRF x94
43D2: CLRF x95
43D4: CLRF x96
43D6: CLRF x97
43D8: CLRF x98
43DA: CLRF x99
43DC: CLRF x9A
43DE: CLRF x9B
43E0: CLRF x9C
43E2: CLRF x9D
43E4: CLRF x9E
43E6: CLRF x9F
43E8: CLRF xA0
43EA: CLRF xA1
43EC: CLRF xA2
43EE: CLRF xA3
43F0: CLRF xA4
43F2: CLRF xA5
43F4: CLRF xA6
43F6: CLRF xA7
43F8: CLRF xA8
43FA: CLRF xA9
43FC: CLRF xAA
43FE: CLRF xAB
4400: CLRF xAC
4402: CLRF xAD
4404: CLRF xAE
4406: CLRF xAF
4408: CLRF xB0
440A: CLRF xB1
440C: CLRF xB2
440E: CLRF xB3
4410: CLRF xB4
4412: CLRF xB5
4414: CLRF xB6
4416: CLRF xB7
4418: CLRF xB8
441A: CLRF xB9
441C: CLRF xBA
441E: CLRF xBB
4420: CLRF xBC
4422: CLRF xBD
4424: CLRF xBE
4426: CLRF xBF
4428: CLRF xC0
442A: CLRF xC1
442C: CLRF xC2
442E: CLRF xC3
4430: CLRF xC4
4432: CLRF xC5
4434: CLRF xC6
4436: CLRF xC7
4438: CLRF xC8
443A: CLRF xC9
443C: CLRF xCA
443E: CLRF xCB
4440: CLRF xCC
4442: CLRF xCD
4444: CLRF xCE
4446: CLRF xCF
4448: CLRF xD0
444A: CLRF xD1
444C: CLRF xD2
444E: CLRF xD3
4450: CLRF xD4
4452: CLRF xD5
4454: CLRF xD6
4456: CLRF xD7
4458: CLRF xD8
445A: CLRF xD9
445C: CLRF xDA
445E: CLRF xDB
4460: CLRF xDC
4462: CLRF xDD
4464: CLRF xDE
4466: CLRF xDF
4468: CLRF xE0
446A: CLRF xE1
446C: CLRF xE2
446E: CLRF xE3
4470: CLRF xE4
4472: CLRF xE5
4474: CLRF xE6
4476: CLRF xE7
4478: CLRF xE8
447A: CLRF xE9
447C: CLRF xEA
447E: CLRF xEB
4480: CLRF xEC
4482: CLRF xED
4484: CLRF xEE
4486: CLRF xEF
4488: CLRF xF0
448A: CLRF xF1
448C: CLRF xF2
448E: CLRF xF3
4490: CLRF xF4
4492: CLRF xF5
4494: CLRF xF6
4496: CLRF xF7
4498: CLRF xF8
449A: CLRF xF9
449C: CLRF xFA
449E: CLRF xFB
44A0: CLRF xFC
44A2: CLRF xFD
44A4: CLRF xFE
44A6: CLRF xFF
44A8: MOVLB 2
44AA: CLRF x00
44AC: CLRF x01
44AE: CLRF x02
44B0: CLRF x03
44B2: CLRF x04
44B4: CLRF x05
44B6: CLRF x06
44B8: CLRF x07
44BA: CLRF x08
44BC: CLRF x09
44BE: CLRF x0A
44C0: CLRF x0B
44C2: CLRF x0C
44C4: CLRF x0D
44C6: CLRF x0E
44C8: CLRF x0F
44CA: CLRF x10
44CC: CLRF x11
44CE: CLRF x12
44D0: CLRF x13
44D2: CLRF x14
44D4: CLRF x15
44D6: CLRF x16
44D8: CLRF x17
44DA: CLRF x18
44DC: CLRF x19
44DE: CLRF x1A
44E0: CLRF x1B
44E2: CLRF x1C
44E4: BCF x1D.0
44E6: CLRF x1E
44E8: CLRF x1F
44EA: CLRF x20
44EC: CLRF x21
44EE: CLRF x22
44F0: CLRF x23
44F2: CLRF x24
44F4: CLRF x25
44F6: CLRF x26
44F8: CLRF x27
44FA: CLRF x28
44FC: CLRF x29
44FE: CLRF x2A
4500: CLRF x2B
4502: CLRF x2C
4504: CLRF x2D
4506: CLRF x2E
4508: MOVLW B8
450A: MOVWF x2F
450C: MOVLW 0B
450E: MOVWF x30
4510: MOVLW 01
4512: MOVWF x31
4514: CLRF x32
4516: CLRF x33
4518: CLRF x34
451A: MOVLW F0
451C: MOVWF x35
451E: MOVLW D2
4520: MOVWF x36
4522: MOVLW 02
4524: MOVWF x37
.................... tGD_UINT32 mainLoopCycles = 0;
4526: CLRF x38
4528: CLRF x39
452A: CLRF x3A
452C: CLRF x3B
.................... tGD_UINT16 rxLoopCounter = 0;
452E: CLRF x3C
4530: CLRF x3D
.................... tsGD_CANPACKET pkt;
.................... tGD_UINT8 eventSet = 0;
4532: CLRF x4A
....................
.................... setup_wdt(WDT_ON);
4534: BSF FD1.0
.................... OSCCON = 0x40; // DEBUG
4536: MOVLW 40
4538: MOVWF FD3
.................... RCON = 0x5F; // DEBUG
453A: MOVLW 5F
453C: MOVWF FD0
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Jun 13, 2008 3:59 pm |
|
|
If you have global variables and you declare them as 'static', then
the compiler will clear them.
The CCS manual says:
Quote: | static
Variable is globally active and initialized to 0. |
|
|
|
|
|
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
|