' ********************************************************************** ' ** Program: Hello_uk.BAS - Version : 1.1 - 30 January 2006 ** ' ** Compiler: Bascom 8051 IDE and LIB 2.0.11.0 ** ' ** Hardware: GMM 932 and GMM 932.11 ** ' ** Firm: grifo(r) ITALIAN TECHNOLOGY ** ' ** Via Dell' Artigiano 8/6 40016 San Giorgio di Piano (BO) ** ' ** Tel.+39 051 892 052 Fax +39 051 893 661 ** ' ** http://www.grifo.com http://www.grifo.it ** ' ** ** ' ** Made by: Graziano GAIBA ** ' ********************************************************************** ' ' Hello_uk.BAS - Rel. 1.1 - 30.01.2006 by Graziano Gaiba ' Program preloaded im mini modules. ' Makes the on-board LED blink. ' ' NOTE: Check presence of 8951CC03.DAT file in BASCOM-8051 root directory and ' copy it if not available; furthermore inside "Options | Compiler | Misc" ' window perform the following settings: ' Register File = 89lpc932.dat ' Byte End(Hex) = A0 ' Size warning = 8191 ' '*********************************************************************** ' '*************************** Compiler directives *********************** ' $regfile "89lpc932.dat" $romstart = &H0 ' Start address of code in FLASH $ramstart = &H0 ' Start address of external RAM $ramsize = &H200 ' 1K bytes of external RAM $crystal = 11059200 ' Microprocessor clock frequency $baud = 19200 ' Serial communication speed $large ' 16 bit addressing $map ' Generates info for each line ' ' '************************* Constants declaration ******************************* ' Const Rcint = 7372800 ' Internal RC clock frequency Const Qz11m = 11059200 ' External crystal clock frequency ' ' '************************* Variables declaration ******************************* ' Dim Cclk As Long ' CPU clock requency Dim R As Word , Del1ms As Word , Del As Word ' Delays management ' ' '************************* Subroutines declaration ***************************** ' Declare Sub Get_clk ' Acquires clock frequency Declare Sub Caldel(del As Word) ' Calibrated delay ' ' ' '***************************** Main program **************************** ' Main: ' Get clock configuration Call Get_clk ' Set as output the TTL signals connected to the LEDs P0m1 = P0m1 Or &H40 ' Set P0.6 in mode 3=OpenDrain P0m2 = P0m2 Or &H40 Do ' Turn on LED P0.6 = 0 ' Pause for 200 milliseconds Call Caldel(200) ' Turn off LED P0.6 = 1 ' Pause for 200 milliseconds Call Caldel(200) ' Loops forever Loop End ' '************************ End of Main program ************************** ' ' ' '********************** General purpose subroutines **************************** ' Reads the configuration byte UCFG1 on FLASH thanks to IAP procedures of ' P89LPC932 Boot Rom. Returns the global variable cclk set with the CPU clock ' frequency, with no control of the possible errors. Sub get_clk mov A,#&H03 ' Uses command Misc. Read mov R7,#&H00 ' Reads register UCFG1 lcall &HFF00 ' Calls IAP proc. at PGM_MTP addr. mov A,R7 ' Saves result anl A,#&H07 ' Masks bits with CPU clock Select Case Acc Case &H00 : cclk = QZ11M ' Ext. crystal clock frequency Case &H03 : cclk = RCINT ' Internal RC clock frequency End Select End Sub ' ' ' Performs a calibrated delay long as many milliseconds as specified in the ' passed parameter del, according with the clock frequency saved in cclk ' variable, with no use of BASCOM instructions that use a fixed and preset ' value of clock. ' ' Sub caldel(del As Word) If cclk = RCINT Then del1ms = 73 ' Value for 1 msec at 7 MHz Else del1ms = 110 ' Value for 1 msec at 11 MHz End If Do For r = 0 To del1ms ' Cycle for 1 msec delay Next r del = del - 1 Loop Until Del = 0 End Sub ' '**************************** End of main program ****************************** '