< title>PIC16f877 Monitor on Linux session

MONITOR OPERATION DEMO SESSION


This session is an example from a pic16f877,erased and programmed with the code jm1.hex. The left column is the Gtkterm terminal screen, [k] indicates keyboard input. Be sure the keyboard capslock is off, and the numlock is on. Whenever you see '>', the monitor is awaiting your keyboard input.




	[powerup]
Jack's Monitor V1.0 	-A clean chip, with no user code will jump to the montior
Run code: 0020		on power-up, wait for a few seconds for a key,and then do
Jack's Monitor V1.0 	a jump to user code space, where it will run 03fff's (addlw)
Run code: 0020		until it hits monitor code at 01d00. This cycle will loop
Jack's Monitor V1.0 	continuously until a key is input.
Run code: 0020
Jack's Monitor V1.0
Run code: 0020			[0] monitor command peek flash memory
					[0000] enter address
>Flash @>0000
0000 158A				[0]
0001 160A				[0]
0002 2D00				[0]   scroll
0003 3FFF				[0]
0002 2D00				[1]
0001 160A				[1] ......ETC
0000 158A

>Flash @>0800
0800 3FFF
0801 3FFF
0802 3FFF
0801 3FFF
0800 3FFF P>0aaa			[p] poke this location with [0aaa]
0800 0AAA
0801 3FFF
0802 3FFF
0801 3FFF
0800 0AAA				[esc]
					[1]  peek ram at [0040]
>Ram @>0040
0040-FB
0041-00
0040-FB (FC FD FE)  		[i][d]  increment, decrement this ram value
0041-00 Poke>aa			[p] poke this ram value
0041-AA
0042-FF
0043-04				[b] toggle bits in the ram byte [k=0-7]
Toggle bit#> 04			[esc][f]

0043-04 Fill>05=aa		-fill this and the next four ram locations with [aa]
0048-FF
0047-AA
0046-AA
0045-AA
0044-AA
0043-AA
0042-FF
0043-AA
					[esc][2] peek eeprom
>Eeprom @>00
00-FF
01-FF=aa				[p] poke [aa] at this address
01-AA					-scroll only works in one direction [any k]
02-FF
03-FF
04-FF
				[esc][3]  load a hex file from the terminal, in this case,
>Load hex			the file is blink.hex, the demo user code
*****************************************************!Run code: 0020
		-each asterisk indicates a successful load of a hexfile line. When all
		of the file is in flash, a jump to user code is executed and user code is
		running.

					-user code blink is now loaded and running. The
					diagnostic code is also loaded (diag.inc)
					[spacebar]
Blink
first,last variables  0026: AA 002B: 00
this is a message
speed_rc0: 0028: 10 			-diag shows program name, some variables, and speed_rc1: 002A: 10 returns to user main code
Running Blink
				[m] -diag does immediate jump to monitor

Blink
				[4] -jumps to init of user code, restart program

>Run code: 0020
				[m],[5] -monitor eeprom dump
Blink

>Eeprom dump

00:FF AA FF FF FF FF AA FF FF FF FF FF FF FF FF FF
10:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
20:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
30:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
40:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
50:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
60:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
70:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
80:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
90:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
A0:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
B0:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
C0:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
D0:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
E0:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
F0:FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
				[esc][6]
>Toggle GIE 20
				[6]-monitor toggle interrupt flag, note effect on RC1
>Toggle GIE A4
				[6]
>Toggle GIE 20

>Toggle GIE A4
				[7]-jumps to 'main' in user code, skipping init
>Goto main
				[spcbar]
Blink
first,last variables  0026: AA 002B: 00
this is a message
speed_rc0: 0028: 10
speed_rc1: 002A: 10
Running Blink
Blink
				[m][1][002a]
>Ram @>002a
002A-10 Poke>40			[p][40]
002A-40				[1]
0029-10				[1]
0028-10 Poke>20			[p][20]
				[7]

Notes:

If GIE is enabled when the monitor is called, the interrupt service will be executed while the monitor code is running. This makes for a very interactive environment with real-time control from the keyboard.

Communicating with the '877 with the interrupts running will sometime result in garbled data from the uart. The interface doesn't use interrupts for obvious reasons, and interrupting the serial timing causes symptoms of an async relationship between the serial and timer clocks. It can look funny but nothing bad comes of it, and because the loader shuts the interrupt enable off, flash memory is never corrupted by the burps.

This diagnostic file is org 01800h, which locks the page three program memory up as resident code, leaving only 6KB for user code. This can be optimized, but I would suggest that if you need more than 6KB of assembly, you might do well to move up a layer or two of abstraction in your relationship with the '877.


back to monitor