'**************************************************************** '* Name : Mini-CW-Geber.mbas * '* Author : Tomtom DL1MFK * '* Notice : Copyright (c) 2011 * '* : All Rights Reserved * '* Date : 15.03.2012 * '* Version : 1.0 * '* Notes : erster Versuch * '* : startet CE-Kennung nach anlegen von 5V an GPIO.0 * '* : + nach 8Min CW-Kennung * '**************************************************************** ' Target PIC : PIC12F683 ' Oscillator : 4MHz internal program mini_cw_geber '****************************************************** '* Variable * '****************************************************** Dim Timer as WORD ' 100ms Zähler dim Zaehler as word Dim Port_Flags as byte Dim Pin_Status as sbit at Port_Flags.0 Dim Pin_Status_alt as sbit at Port_Flags.1 Dim Sync_an as sbit at Port_Flags.2 '****************************************************** '* Konstanen * '****************************************************** const cw_dit = 60 ' 50ms const cw_dah = 3 * cw_dit ' 150ms const cw_f = 833 ' CW Ton = 833Hz '****************************************************** '* Prozeduren * '****************************************************** sub procedure Interrupt() Inc(Zaehler) ' Increment value of counter on every interrupt PIR1.TMR1IF = 0 ' clear TMR1IF TMR1L = 0x9F ' 4MHz/4 = 1MHz = 1uS*(65535-5535) = 0,06s TMR1H = 0x15 end sub sub procedure OE7PKI() 'O Sound_Play(CW_F, cw_dah) Delay_ms(cw_dit) Sound_Play(CW_F, cw_dah) Delay_ms(cw_dit) Sound_Play(CW_F, cw_dah) Delay_ms(cw_dah) 'E Sound_Play(CW_F, cw_dit) Delay_ms(cw_dah) '7 Sound_Play(CW_F, cw_dah) Delay_ms(cw_dit) Sound_Play(CW_F, cw_dah) Delay_ms(cw_dit) Sound_Play(CW_F, cw_dah) Delay_ms(cw_dit) Sound_Play(CW_F, cw_dit) Delay_ms(cw_dit) Sound_Play(CW_F, cw_dit) Delay_ms(cw_dah) 'P Sound_Play(CW_F, cw_dit) Delay_ms(cw_dit) Sound_Play(CW_F, cw_dah) Delay_ms(cw_dit) Sound_Play(CW_F, cw_dah) Delay_ms(cw_dit) Sound_Play(CW_F, cw_dit) Delay_ms(cw_dah) 'K Sound_Play(CW_F, cw_dah) Delay_ms(cw_dit) Sound_Play(CW_F, cw_dit) Delay_ms(cw_dit) Sound_Play(CW_F, cw_dah) Delay_ms(cw_dah) 'I Sound_Play(CW_F, cw_dit) Delay_ms(cw_dit) Sound_Play(CW_F, cw_dit) Delay_ms(1000) end sub '****************************************************** '* Hauptprogramm Schleife * '****************************************************** Main: TRISIO = %00000100 ' Input Output GP1 input GPIO.1=0 ' PTT aus GPIO.4=1 ' Logo aus Zaehler = 20 ' Logo Abschaltzähler ANSEL = 0 ' Alle IOs Digital CMCON0 = 7 ' Comperatoren aus Port_Flags = 0 ' alle Flags aus T1CON = 1 ' Timer1 settings PIR1.TMR1IF = 0 ' clear TMR1IF TMR1L = 0x9F ' 4MHz/4 = 1MHz = 1uS*(65535-5535) = 0,06s TMR1H = 0x15 PIE1.TMR1IE = 1 ' enable Timer1 interrupt INTCON = 0xC0 ' Set GIE, PEIE Sound_Init(GPIO, 5) ' Sound initialisieren while TRUE ' Endlosschleife Pin_status_alt = Pin_Status ' alten Sync-Zustand sichern Pin_status = GPIO.2 ' Sync-Zustand einlesen If (Pin_status_alt=0) and (Pin_status = 1) then 'Wenn sich der Status ändert dann Timer = 4799 ' Timer frisch setzen zum Ausgeben end if Delay_ms(100) ' 100ms warten inc(Timer) ' 8Min Zähler erhöhen ' Nach 8 Minuten CW und Logo ausgeben wenn PTT ein If (Timer = 4800) and (GPIO.1=1) Then ' 4800 * 0,1s = 480s = 8 Min GPIO.1=1 ' PTT ein GPIO.4=0 ' Logo ein Timer = 0 ' 8 Min Zähler zurücksetzen Zaehler = 0 ' 25sec Zähler zurücksetzen PIE1.TMR1IE = 1 ' enable Timer1 interrupt delay_ms(1000) OE7PKI() ' nach 1s Call ausgeben end if ' Logo nach 30 sek ausschalten If (Zaehler > 500) then ' 500*0,06s = 30s GPIO.4=1 ' Logo aus Zaehler = 0 'Sound_Play(3000, 100) PIE1.TMR1IE = 0 ' disable Timer1 interrupt end if If (Pin_status_alt=1)and(Pin_status=0) then ' Ausschalten GPIO.4=1 ' Logo aus delay_ms(1000) OE7PKI() ' nach 1s Call ausgeben GPIO.1=0 ' PTT aus end if wend ' Hauptschleife end.