SIMPLE TBAS-52 TEST PROGRAMS FOR TUC-52 Here are several simple BASIC test programs developed by Dan Karmann (dankarmann@lucent.com) that use various means to flash the LED on the TUC-52 board as well as a sample scenario to verify program storage in the battery-backed RAM (BBRAM). Use "Save As" on your Web browser to save these files to your as text, then use your favorite editor to isolate the program of interest, download to TUC52 and run it. ---------------------------------------------------------------------- File: TUCLED1.BAS This first program initializes the 82C55 and outputs an alternating 00h and FFh value to its Port A to flash the LED. A software delay loop sets the flash rate. A jumper must be installed on header H23 for the LED to flash. 5 REM TUC-52 Simple LED Flash Test (jumper must be on H23) 10 APORT=0F8FCH : REM IC13 (82C55) Port A address 20 CTRL=0F8FFH : REM IC13 Control port address 30 XBY(CTRL)=80H : REM Make IC13 Port A all outputs 40 X=0 : REM Output value variable initialization 50 XBY(APORT)=X : REM Output to Port A (LED is bit 7) 60 X=NOT(X).AND.0FFH : REM Toggle output variable value 70 FOR I=1 TO 1000 : REM Wait about 1 second 80 NEXT I 85 A=GET : REM Check for input from user 86 IF A<>0 THEN END : REM Quit if so 90 GOTO 50 : REM Otherwise, do forever ---------------------------------------------------------------------- File: TUCLED2.BAS This second program initializes the 82C55 and outputs an alternating 00h and FFh value to its Port A to flash the LED. The built-in BASIC Timer is used to set the flash rate. A jumper must be installed on header H23 for the LED to flash. 5 REM TUC-52 Timer-based LED Flash Test (jumper must be on H23) 10 APORT=0F8FCH : REM IC13 (82C55) Port A address 20 CTRL=0F8FFH : REM IC13 Control port address 30 XBY(CTRL)=80H : REM Make IC13 Port A all outputs 40 X=0 : REM Output value variable initialization 50 TIME=0 : T=0 : CLOCK 1 : REM Start BASIC Timer 60 ONTIME T+1,100 : REM Set Timer to interrupt in 1 second 70 A=GET : REM Check for input from user 80 IF A<>0 THEN END : REM Quit if so 90 GOTO 70 : REM Otherwise, do forever REM Timer Interrupt 100 T=TIME : REM Save current time 110 XBY(APORT)=X : REM Output to Port A (LED is bit 7) 120 X=NOT(X).AND.0FFH : REM Toggle output variable value 130 ONTIME T+1,100 : REM Set Timer to interrupt in 1 second 140 RETI : REM Timer interrupt completed ---------------------------------------------------------------------- TUCLED3.BAS This third program initializes the 82C55 and outputs an alternating 00h and 80h value to its Port A to flash the LED using the XBIT enhanced instruction with a shadow register. A software delay loop sets the flash rate. A jumper must be installed on header H23 for the LED to flash. 5 REM TUC-52 XBIT LED Flash Test (jumper must be on H23) 10 APORT=0F8FCH : REM IC13 (82C55) Port A address 20 CTRL=0F8FFH : REM IC13 Control port address 30 XBY(CTRL)=80H : REM Make IC13 Port A all outputs 40 SHPORT=MTOP+1 : REM Reserve a shadow register above MTOP 50 XBY(APORT)=XBY(SHPORT) : REM Output shadow value to Port A 60 XBIT(SHPORT,7)=XBIT(SHPORT,7).XOR.1 : REM Toggle shadow LED bit 70 FOR I=1 TO 1000 : REM Wait about 1 second 80 NEXT I 85 A=GET : REM Check for input from user 86 IF A<>0 THEN END : REM Quit if so 90 GOTO 50 : REM Otherwise, do forever ---------------------------------------------------------------------- TUCLED4.BAS This fourth program initializes the 82C55 and outputs an alternating 00h and 80h value to its Port A to flash the LED. The RTC clock is read to determine the flash rate using the "Read Seconds since Midnight" function. A jumper must be installed on header H23 for the LED to flash. 5 REM TUC-52 RTC-based LED Flash Test (jumper must be on H23) 10 APORT=0F8FCH : REM IC13 (82C55) Port A address 20 CTRL=0F8FFH : REM IC13 Control port address 30 XBY(CTRL)=80H : REM Make IC13 Port A all outputs 35 GOSUB 100 : REM Make sure clock is running 40 CALL 2100H,SECS : REM Read Seconds since Midnight 50 IF SECS>65536 THEN SECS=SECS-65536 : REM Make value fit into 16 bits 60 IF SECS=S GOTO 85 : REM Check for a new second 70 S=SECS : REM Yes, save current second value 80 XBY(APORT)=(SECS.AND.1)*80H : REM Output LSB value to Port A in bit 7 85 A=GET : REM Check for input from user 86 IF A<>0 THEN END : REM Quit if so 90 GOTO 40 : REM Otherwise, do forever REM Subroutine to ensure that clock is running 100 XBY(MTOP+1)=4 : REM PCF8583 clock enable value 110 CALL 2110H,0A0H,1,MTOP+1,0 : REM Set PCF8583 control register 120 RETURN ---------------------------------------------------------------------- This section outlines a way to verify operation of the battery-backed RAM (BBRAM) to save and execute BASIC programs. 1) Load one of the above LED test programs onto the TUC-52 board. 2) Verify the LED flashes when the program runs. 3) Save the program in BBRAM using the "PROG" command as follows: PROG 1 (this is the response) READY > 4) Remove the program from RAM with the "NEW" command and verify it no longer exists with the "LIST" command. 5) Select the saved program with the "ROM" command and verify it exists with the "LIST" command. 6) Verify that the BBRAM mode is selected by attempting to enter a new line of code and getting an error as follows: 1 REM ERROR: PROM MODE (this is the response) 7) Verify the program runs (the LED flashes) by using the "RUN" command. 8) Make this program an auto-start program by using the "PROG4" command. 9) Verify the program automatically flashes the LED from power-up by power-cycling the TUC-52 board. If it does not automatically start, make sure that the jumpers are installed on both H9 and H10 on the right two pins (not their left two pins) for battery-backed operation. 10) Use the "PROG", "RAM", "ROM", "XFER", and "ERASE/ERASEn" commands to save/select/move/remove additional BASIC programs. ---ooOoo---