' ********************************************************************** ' * File: uk_BAS51_005.BAS * ' * Version: 1.1 * ' * Date: 26.04.10 * ' * Development Tools: Bascom 8051 COMP.,IDE 2.0.14.0 + FLIP 2.4.6 * ' * Cards: GMM 5115 + GMM TST3 * ' * Developed by: GRIFO(r) Italian Technology * ' * via Dell'Artigiano 8/6 * ' * 40016 S. Giorgio di Piano (BO) * ' * Tel. +39 051 892052 Fax. +39 051 893661 * ' * http://www.grifo.com http://www.grifo.it * ' * Author: Gianluca Angelini * ' ********************************************************************** ' Example program 005 of BASCOM 8051 course. ' It executes simple operations on digital I/O, by using the GMM 5115 on board ' LED. ' The program generates a base timing of one second that changes status to ' activity LED DL1. The base timing is generated by a calibrated loop plus ' the suited DELAY instruction of BASCOM 8051, that generates a delay of about ' 100 microseconds. ' ' Added instructions: DELAY. ' ' 26/04/10: uk_BAS51_005.BAS - Ver 1.1 - By G.A. ' First version. ' ' '**************************** IDE Configurations ******************************* ' NOTE: in order to coorectly use this demo program, please execute the following ' steps: ' 1) Check the availability of 89C5115.DAT file into the directory where the ' BASCOM 8051 is installed and copy it if not present. ' 2) Into the window "Options | Compiler | Misc" set: ' Register File = 89C5115.DAT ' Byte End(Hex) = A0 ' Size warning = selected at 16384 (=4000H) '************************* Compiler directives ********************************* $regfile "89C5115.DAT" ' Definitions file for used microcontroller $romstart = &H0 ' Code start address on FLASH $iramstart = &H0 ' Data start address on internal RAM $ramstart = &H0 ' Data start address on external RAM $ramsize = &H100 ' External RAM size $crystal = 14745600 ' Microcontroller crystal frequency $large ' Code size > 2K $map ' Generate debug information '******************************* Definitions *********************************** ' The resources used by program are connected as described in following table: ' ' Resource GMM TST3 Z1 pin GMM 5115 pin uP signal ' LED DL1 33 27 P1.0 Pindl1 Alias P1.0 ' Signal connected DL1 on GMM 5115 '************************* Constants declaration ******************************* Const Del1sec = 5350 ' Cycles number to obtain 1 sec delay (experimentally calibrated) '************************* Variables declaration ******************************* Dim Dl1stat As Bit ' Boolean variable for DL1 LED status Dim Del As Long ' Cycles counter variable for delay '************************ Subroutines declaration ****************************** '****************************** Main program *********************************** Main: Pindl1 = 1 ' Initialize signal connected to DL1 as digital output, high Dl1stat = 1 ' Initialize DL1 status as disabled Do ' Begin endless loop Dl1stat = Not Dl1stat ' Invert variable with DL1 status Pindl1 = Dl1stat ' Set DL1 LED with new status ' Perform 1 second delay: a loop performs a short delay through DELAY instruction and it waits ' that Del variable (cycles counter for delay) reaches the value saved in Del1sec constant. ' This value (5350) is experimentally calibrated, or established through tests Del = 0 ' Reset cycles counter for delay Do ' Begin loop for 1 second delay Delay ' Perfor a delay of about 100 microseconds Del = Del + 1 ' Increase cycles counter for delay Loop Until Del > Del1sec ' End loop for delay Loop ' End endless loop End '*************************** End of main program *******************************