'------------------------------------------------------------------ ' MAX6 test DDS line ' By Jarek SP3SWJ sp3swj@gmail.com ' Created with Bascom-Avr: 1.11.9.3 '------------------------------------------------------------------ $regfile = "m128def.dat" $crystal = 11059200 $baud = 115200 ' use baud rate $loadersize = 1024 '$hwstack = 128 '$swstack = 128 '$framesize = 196 'some routines to control the display are in the glcdKS108.lib file 'First we define that we use a graphic LCD KS0108 $lib "glcdKS108.lbx" Config Graphlcd = 128 * 64sed , Dataport = Porta , Controlport = Portc , Ce = 7 , Ce2 = 6 , Cd = 3 , Rd = 4 , Reset = 5 , Enable = 2 Config Timer1 = Pwm , Prescale = 1 , Pwm = 8 , Compare B Pwm = Clear Down 'The AUTO feature, will select the highest clockrate possible Config Adc = Single , Prescaler = Auto Config Pinb.4 = Input '1=on-MAX 0=0ff-MAX - start OFF Key_power_on Alias Pinb.4 Key_power_on_pullup Alias Portb.4 Config Portb.5 = Output Buzer Alias Portb.5 'use as PWM backlit output Portb.6 'POWER on SWITCH 1=ON Config Porte.7 = Output Switch_power_on Alias Porte.7 'ON=1 OFF=0 '========================================== Config Portd.4 = Output Dds_fqud Alias Portd.4 Config Portd.5 = Output Dds_data Alias Portd.5 Config Portd.6 = Output Dds_clock Alias Portd.6 Config Portd.7 = Output Dds_reset Alias Portd.7 '========================================== Config Pine.2 = Input Key_function Alias Pine.2 Key_function_pullup Alias Porte.2 Config Pine.3 = Input Key_mode Alias Pine.3 Key_mode_pullup Alias Porte.3 Config Pine.4 = Input Key_down Alias Pine.4 Key_down_pullup Alias Porte.4 Config Pine.5 = Input Key_up Alias Pine.5 Key_up_pullup Alias Porte.5 Config Pind.1 = Input ' USB=0 LCD=1 Key_lcd_mode Alias Pind.1 Key_lcd_mode_pullup Alias Portd.1 '=============================================================================== Dim Lcd_light As Byte Dim Second_old As Byte '============================== START ====================================== Cls 'provide pull-up for KEYBOARD Set Key_function_pullup Set Key_down_pullup Set Key_up_pullup Set Key_mode_pullup Set Key_power_on_pullup Set Key_lcd_mode_pullup Lcd_light = 0 Setfont Font16x16 Reset Switch_power_on Lcdat 2 , 1 , "HOLD PWR" Wait 1 Pwm1b = Lcd_light Set Switch_power_on Lcdat 2 , 1 , "RELASE !" Do Toggle Buzer Waitus 500 Loop Until Key_power_on = 1 Pwm1b = 255 Wait 1 Cls Setfont Font8x8 Do Pwm1b = Lcd_light Incr Lcd_light 'Waitms 100 Toggle Buzer 'Print "TEST MAX6 " ; Lcd_light '----------------------- If Key_mode = 1 Then Lcdat 1 , 1 , "MODE=1 portD.5=1" Dds_data = 1 Else Lcdat 1 , 1 , "MODE=0 portD.5=0" Dds_data = 0 End If '---------------------- '----------------------- If Key_function = 1 Then Lcdat 3 , 1 , "FUNC=1 portD.4=1" Dds_fqud = 1 Else Lcdat 3 , 1 , "FUNC=0 portD.4=0" Dds_fqud = 0 End If '---------------------- '----------------------- If Key_down = 1 Then Lcdat 5 , 1 , "DOWN=1 portD.7=1" Dds_reset = 1 Else Lcdat 5 , 1 , "DOWN=0 portD.7=0" Dds_reset = 0 End If '---------------------- '----------------------- If Key_up = 1 Then Lcdat 7 , 1 , "UP =1 portD.6=1" Dds_clock = 1 Else Lcdat 7 , 1 , "UP =0 portD.6=0" Dds_clock = 0 End If '---------------------- '---------------------- If Key_power_on = 0 Then Setfont Font16x16 Cls Lcdat 3 , 30 , "OFF" Reset Switch_power_on Do Toggle Buzer Waitus 500 Loop Until Key_power_on = 1 End If '---------------------- Lcdat 8 , 1 , Lcd_light Loop 'we need to include the font files $include "font8x8.font" $include "font16x16.font"