Differences

This shows you the differences between two versions of the page.

Link to this comparison view

projects:icspio [2014/12/23 18:18]
127.0.0.1 external edit
projects:icspio [2017/01/12 22:44]
Line 1: Line 1:
-==== ICSP I/O ==== 
- 
-ICSP I/O is a protocol and group of functions designed 
-to quickly develop test code for the devices supported 
-by the k8048 Microchip PIC programmer. 
- 
-It uses the I/O lines used by the ICSP programming 
-protocol and is compatible with bit-bang programmers such as 
-the Velleman K8048. 
- 
-ICSP I/O was not designed a replacement for more established 
-and more reliable protocols but it can be used for prototyping. 
- 
-==== Usage==== 
- 
-<code> 
-#INCLUDE        "device.inc"   ;DEVICE CONFIG 
-#INCLUDE        "const.inc"    ;CONSTANTS 
-#INCLUDE        "macro.inc"    ;MACROS 
-#INCLUDE        "delay.inc"    ;DELAY COUNTERS 
-#INCLUDE        "shadow.inc"   ;SHADOW I/O (ONLY USE IF DEVICE HAS NO LATCH) 
-NPINS           SET     .18    ;18-PIN PDIP 
-#INCLUDE        "icspio.inc"   ;ICSP I/O 
-</code> 
- 
-Internal variable addresses are assigned at the current CBLOCK address. It is up to 
-the main source file to ensure that this address is both valid and that there is enough space for allocation. 
- 
-==== Demo ==== 
- 
-== Set LEDs and read switches in a loop == 
-<code> 
-ktest 5 ARG 
-</code> 
- 
-== Set LEDs and read switches from the command line == 
-<code> 
-kio CMD ARG 
-Src/etc/led.sh 
-Src/etc/switch.sh 
-</code> 
- 
-==== Functions ===== 
- 
-== GETBYTE == 
-Fetches a byte from the master (host) and stores it in BUFFER.\\ 
-Sets W and also sets the carry bit on error (time-out, protocol or 
-parity error). 
- 
-== SENDBYTE == 
-Sends a byte in W to the master (host).\\ 
-Sets W and also sets the carry bit on a time-out error. 
-  
-== SENDACK == 
-Calls SENDBYTE with W=ACK (acknowledge) 
- 
-== SENDNAK == 
-Calls SENDBYTE with W=NAK (negative acknowledge) 
- 
-2 levels of stack are used when calling the routines GETBYTE, SENDBYTE or 
-SENDTERM. On 12-bit word architecture devices do not call any of these 
-routines from within a sub-routine since it will overflow the stack. 
- 
-==== Protocol ===== 
- 
-PGD is used for data I/O with even parity and PGC for clock synchronisation. 
-PGC is unidirectional and is only controlled by the master (host), this is the 
-slave. The interface may or not be inverted but this is catered for by the 
-k8048 Microchip PIC programmer BITRULES inversion logic. 
- 
-Data is setup on the master prior to a clock low to high transition and setup 
-on the slave after a clock low to high transition. Data is read after a clock 
-high to low transition on both master and slave. 
- 
-Start and stop bits have data held low and high respectively and if invalid 
-then a protocol error is flagged and the transaction terminated without further 
-communication on either end. Parity error causes a similar closure of the 
-session. 
- 
-<code> 
- PGC   +--+  +--+  +--+  +--+  +--+  +--+  +--+  +--+  +--+  +--+  +--+ 
-        |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | 
- ------+  +--+  +--+  +--+  +--+  +--+  +--+  +--+  +--+  +--+  +--+  +------- 
- PGD   START DATA  DATA  DATA  DATA  DATA  DATA  DATA  DATA  EVEN  STOP 
- XXXXXXLLLLLL000000111111222222333333444444555555666666777777PPPPPPHHHHHHHHHHH 
-       BIT   BIT0  BIT1  BIT2  BIT3  BIT4  BIT5  BIT6  BIT7  PAR.  BIT 
-</code> 
- 
-1 start bit, 8 data bits, even parity and one stop bit. The data line is 
-normally held high since in order to operate bi-directionally data output must 
-be held high in order for data input to operate with the Velleman K8048. 
- 
-==== Reference ==== 
- 
-^Arch. ^Stack level| 
-| 12   | 2  | 
-| 14   | 8  | 
-| 16   | 31 | 
-