- Akku Tests und Balkonkraftwerk Speicher         
Seite 2 von 2 ErsteErste 12
Ergebnis 11 bis 13 von 13

Thema: RFM12-Artikel im Elektor - jemand Erfahrung damit???

  1. #11
    Erfahrener Benutzer Begeisterter Techniker
    Registriert seit
    25.03.2006
    Ort
    Hinsdorf
    Alter
    49
    Beiträge
    381
    Anzeige

    LiFePo4 Akku selber bauen - Video
    Hallo,

    auch ich möchte in der nächsten Zeit mit dem RFM-Modul arbeiten und dazu habe ich eine Seite gefunden: http://www.flashcraft.de/index.php?lang=de
    die Dich interessieren könnte!
    Florian hat ein Board und auch eine funktionierende Software erstellt, die das RFM12 über RS232 anspricht. Er nutzt dazu einen mega32 der sich um alle Arbeiten zum senden/empfangen kümmert und du nur noch das Modul über RS232 ansprechen musst!
    Gruß MAT

  2. #12
    Erfahrener Benutzer Begeisterter Techniker
    Registriert seit
    18.05.2007
    Beiträge
    329
    Soooo:

    2 ATMega8 an einem ein Taster am anderen eine LED

    2 Pollin RFM12 mit 434Mhz

    Code:
    'Elektor RFM12 Sender
    
    $regfile = "m8def.dat"
    $hwstack = 32
    $swstack = 10
    $framesize = 40
    
    $crystal = 16000000
    $baud = 19200
    
    Nsel Alias Portb.2
    Sdi Alias Portb.3
    Sdo Alias Pinb.4
    Sck Alias Portb.5
    
    Dim D As Word
    Dim Data_in(10) As Byte
    Dim Data_out(10) As Byte
    Dim N As Byte
    Dim Timeout As Word
    Dim T As Word
    Dim Tt As Word
    Dim Freq As Single
    
    Declare Sub Send_rfm12
    Declare Sub Receive_rfm12
    Declare Sub Freq_rfm12
    Declare Sub Wait_rfm12
    Declare Function Spi16(byval Dout As Word) As Word
    
    Config Nsel = Output
    Config Sdi = Output
    Config Sck = Output
    Config Portc.5 = Output
    Config Pinc.4 = Input
    Pinc.4 = 1
    
    'Init
      Nsel = 1
      Sck = 0
     D = Spi16(&H80d7)                                          ' El , Ef , 11.5pf, 433 MHz band
      'D = Spi16(&H80e7)                                         ' El , Ef , 11.5pf, 868 MHz band
      D = Spi16(&H82d9)                                         '!er , !ebb , Et , Es , Ex , !eb , !ew , Dc
      D = Spi16(&Ha67c)                                         ' 434,15 MHz / 868,3 MHz
      D = Spi16(&Hc647)                                         ' 4.8kbps
      D = Spi16(&H94a4)                                         ' Vdi , Fast , 134 kHz , 0db , -79dbm
      D = Spi16(&Hc2ac)                                         ' Al , !ml , Dig , Dqd4
      D = Spi16(&Hca81)                                         ' Fifo8 , Sync , !ff , Dr
      D = Spi16(&Hc483)                                         ' @pwr , No Rstric , !st , !fi , Oe , En
      D = Spi16(&H9850)                                         ' 90 kHz , power - 0 dB
      D = Spi16(&He000)                                         '
      D = Spi16(&Hc800)                                         '
      D = Spi16(&Hc000)                                         ' 1 MHz , 2.2V
    
    
     Do
        For N = 1 To 10
          Data_out(n) = 6
        Next N
        If Pinc.4 = 0 Then
        Data_out(2) = 12
        Else
        Data_out(2) = 10
        End If
        Send_rfm12
        Waitms 500
        For N = 1 To 10
           Data_in(n) = 0
        Next N
        Timeout = 400 + Rnd(1000)
        Receive_rfm12
        For N = 1 To 10
           Print Data_in(n);
           Print " ";
        Next N
        Waitms 700
     Loop
    
    
    Sub Freq_rfm12
      If Freq < 800 Then Freq = Freq * 2
      Freq = Freq - 860
      D = Freq / 0.0050
      If D < 96 Then D = 96
      If D > 3903 Then D = 3903
      D = D + &HA000
      D = Spi16(d)
    End Sub
    
    
    Sub Send_rfm12
      D = Spi16(&H8238)
      Wait_rfm12
      D = Spi16(&Hb8aa)
      Wait_rfm12
      D = Spi16(&Hb8aa)
      Wait_rfm12
      D = Spi16(&Hb8aa)
      Wait_rfm12
      D = Spi16(&Hb82d)
      Wait_rfm12
      D = Spi16(&Hb8d4)
      For N = 1 To 10
        Wait_rfm12
        D = &HB800 + Data_out(n)
        D = Spi16(d)
      Next N
      Wait_rfm12
      D = Spi16(&Hb8aa)
      Wait_rfm12
      D = Spi16(&Hb8aa)
      Wait_rfm12
      D = Spi16(&H8208)
    End Sub
    
    Sub Wait_rfm12
      Nsel = 0
      Do
      Loop Until Sdo = 1
    End Sub
    
    
    Sub Receive_rfm12
      Tt = Timeout * 10
      D = Spi16(&H82c8)
      D = Spi16(&Hca83)
      For N = 1 To 10
        Nsel = 0
        T = 0
        Do
          T = T + 1
          Waitus 100
          If T > Tt Then Goto Nosignal
        Loop Until Sdo = 1
        D = Spi16(&Hb000)
        Data_in(n) = D
      Next N
    Nosignal:
      D = Spi16(&H8208)
    End Sub
    
    
    Function Spi16(byval Dout As Word) As Word
    Local Nspi As Integer
    Local Dspi As Integer
    Local Dsdo As Word
      Nsel = 0
      Dsdo = 0
      For Nspi = 1 To 16
        Dspi = Dout And &H8000
        If Dspi = 0 Then
           Sdi = 0
        Else
           Sdi = 1
        End If
        Dout = Dout * 2
        Dsdo = Dsdo * 2
        Dsdo = Dsdo + Sdo
        Sck = 1
        Waitus 5
        Sck = 0
      Next Nspi
      Nsel = 1
      Spi16 = Dsdo
    End Function
    Empfänger:

    Code:
    'Elektor RFM12 Empfänger
    
    $regfile = "m8def.dat"
    $hwstack = 32
    $swstack = 10
    $framesize = 40
    
    $crystal = 16000000
    $baud = 19200
    
    Nsel Alias Portb.2
    Sdi Alias Portb.3
    Sdo Alias Pinb.4
    Sck Alias Portb.5
    
    Dim D As Word
    Dim Data_in(10) As Byte
    Dim Data_out(10) As Byte
    Dim N As Byte
    Dim Timeout As Word
    Dim T As Word
    Dim Tt As Word
    Dim Freq As Single
    
    Declare Sub Send_rfm12
    Declare Sub Receive_rfm12
    Declare Sub Freq_rfm12
    Declare Sub Wait_rfm12
    Declare Function Spi16(byval Dout As Word) As Word
    
    Config Nsel = Output
    Config Sdi = Output
    Config Sck = Output
    Config Portc = Output
    
    'Init
      Nsel = 1
      Sck = 0
     D = Spi16(&H80d7)                                          ' El , Ef , 11.5pf, 433 MHz band
      'D = Spi16(&H80e7)                                         ' El , Ef , 11.5pf, 868 MHz band
      D = Spi16(&H82d9)                                         '!er , !ebb , Et , Es , Ex , !eb , !ew , Dc
      D = Spi16(&Ha67c)                                         ' 434,15 MHz / 868,3 MHz
      D = Spi16(&Hc647)                                         ' 4.8kbps
      D = Spi16(&H94a4)                                         ' Vdi , Fast , 134 kHz , 0db , -79dbm
      D = Spi16(&Hc2ac)                                         ' Al , !ml , Dig , Dqd4
      D = Spi16(&Hca81)                                         ' Fifo8 , Sync , !ff , Dr
      D = Spi16(&Hc483)                                         ' @pwr , No Rstric , !st , !fi , Oe , En
      D = Spi16(&H9850)                                         ' 90 kHz , power - 0 dB
      D = Spi16(&He000)                                         '
      D = Spi16(&Hc800)                                         '
      D = Spi16(&Hc000)                                         ' 1 MHz , 2.2V
    
     Do
        For N = 1 To 10
          Data_out(n) = N
        Next N
        Send_rfm12
        Waitms 500
        For N = 1 To 10
           Data_in(n) = 0
        Next N
        Timeout = 400 + Rnd(1000)
        Receive_rfm12
        For N = 1 To 10
           Print Data_in(n);
           Print " ";
        Next N
        Waitms 700
        If Data_in(2) = 12 Then
         Portc.5 = 1
         Else
         Portc.5 = 0
         End If
     Loop
    
    
    Sub Freq_rfm12
      If Freq < 800 Then Freq = Freq * 2
      Freq = Freq - 860
      D = Freq / 0.0050
      If D < 96 Then D = 96
      If D > 3903 Then D = 3903
      D = D + &HA000
      D = Spi16(d)
    End Sub
    
    
    Sub Send_rfm12
      D = Spi16(&H8238)
      Wait_rfm12
      D = Spi16(&Hb8aa)
      Wait_rfm12
      D = Spi16(&Hb8aa)
      Wait_rfm12
      D = Spi16(&Hb8aa)
      Wait_rfm12
      D = Spi16(&Hb82d)
      Wait_rfm12
      D = Spi16(&Hb8d4)
      For N = 1 To 10
        Wait_rfm12
        D = &HB800 + Data_out(n)
        D = Spi16(d)
      Next N
      Wait_rfm12
      D = Spi16(&Hb8aa)
      Wait_rfm12
      D = Spi16(&Hb8aa)
      Wait_rfm12
      D = Spi16(&H8208)
    End Sub
    
    Sub Wait_rfm12
      Nsel = 0
      Do
      Loop Until Sdo = 1
    End Sub
    
    
    Sub Receive_rfm12
      Tt = Timeout * 10
      D = Spi16(&H82c8)
      D = Spi16(&Hca83)
      For N = 1 To 10
        Nsel = 0
        T = 0
        Do
          T = T + 1
          Waitus 100
          If T > Tt Then Goto Nosignal
        Loop Until Sdo = 1
        D = Spi16(&Hb000)
        Data_in(n) = D
      Next N
    Nosignal:
      D = Spi16(&H8208)
    End Sub
    
    
    Function Spi16(byval Dout As Word) As Word
    Local Nspi As Integer
    Local Dspi As Integer
    Local Dsdo As Word
      Nsel = 0
      Dsdo = 0
      For Nspi = 1 To 16
        Dspi = Dout And &H8000
        If Dspi = 0 Then
           Sdi = 0
        Else
           Sdi = 1
        End If
        Dout = Dout * 2
        Dsdo = Dsdo * 2
        Dsdo = Dsdo + Sdo
        Sck = 1
        Waitus 5
        Sck = 0
      Next Nspi
      Nsel = 1
      Spi16 = Dsdo
    End Function
    Es lief erst zuverlässig, nachdem ich die Fusebits SUT0 und SUT1 gelöcht (also aktiviert) habe. Der Prozessor hat jetzt mehr Zeit zum Einschwingen.

    Günter

  3. #13
    Neuer Benutzer Öfters hier
    Registriert seit
    08.03.2005
    Ort
    Bayern
    Alter
    55
    Beiträge
    14
    Hallo

    ich habe mich mal rumgespielt mit den Modulen und ein Programm mit Interrupt geschrieben.

    2 x Atmega8 , 2x RFM12 , Modul sendet nach 1 min einen Text an das andere, Befehle von der Com werden gesendet, SPi Befehle von der Com werden in das Modul geschrieben.

    Beispiel:
    Com1: >TXD_Hallo + CHR13 sendet Hallo ans andere Modul und dieses gibt es mit Print aus.

    Com1: >SPI_47274 + Chr(13) schreibt B8AA ans Modul

    Com1: >INI_0 + Chr(13) Modul wird nochmal Init

    Com1: >STA_0000 + CHr(13) liest Statusregister vom Modul und gibt es aus.


    Viel Spaß

    Mfg

    Code:
    '######################## RFM12  sende/empfang Test mit Interrupt made by Tomi0815 ######################################
    '
    'Test 2x ATMega8 und 2x RFM12
    '
    '
    '
    ' M8  / PB5       -->  RFM12 / SCK
    ' M8  / PB4       -->  RFM12 / SDO
    ' M8  / PB3       -->  RFM12 / SDI
    ' M8  / PB2       -->  RFM12 / nSEL  --> Wiederstand (10K) nach VCC (Pullup nSEL = High beim Programmieren des M8)
    ' M8  / PD2(INT0) -->  RFM12 / nIRQ
    '
    '
    ' M8  / PD7       -->  Taster nach GND ( Starte Teststring schleife )
    ' M8  / PB0       -->  LED K -|<|- A --> Wiederstand --> VCC  ( Kontrolle )
    '
    ' RFM12 / FSK-Data --> Wiederstand(1K) nach VCC
    ' RFM12 VDD / GMD / Antenne
    '
    ' OSCCAL für Print an ATMEGA8 anpassen
    '
    '
    ''####################################################################################################################
    
    $regfile = "m8def.dat"
    $hwstack = 64
    $swstack = 20
    $framesize = 40
    
    $crystal = 8000000
    $baud = 19200
    
    Baud = 19200
    
    Osccal = 195
    
    '##################################################################################################################   dim,conf
    
    Const Sync_byte = 62
    
    Dim Sek_timer As Long : Sek_timer = 0
    
    '-------------------------------------------------------------------------------    für TX/RX
    Dim Buffer As String * 32
    Dim Buffer_len As Byte
    Dim Buffer_wert As Word
    
    Dim Startbit As Bit
    Dim Split_buffer_1 As String * 15
    Dim Split_buffer_2 As String * 15
    
    Dim Rxd_byte As Byte
    Dim Rxd_buffer_len As Byte
    Dim Rxd_in_counter As Byte
    Dim Rxd_buffer As String * 32
    
    
    Dim Txd_buffer As String * 32
    Dim Txd_len As Byte
    Dim Txd_byte_counter As Byte
    Dim Txd_byte As Byte
    Dim Txd_string As String * 1
    
    '-------------------------------------------------------------------------------    für RFM12
    Dim Daten_empfangen As Bit : Daten_empfangen = 0
    
    Dim Rfm12_rxd_len As Byte
    
    Dim Rfm12_txd_string As String * 50
    Dim Rfm12_rxd_string As String * 50
    
    Dim Rfm12_rxd_bit_counter As Byte
    Dim Rfm12_rxd_bit_counter2 As Byte
    Dim Rfm12_rxd_data_counter As Byte
    Dim Rfm12_rxd_byte As Byte
    
    Dim Rfm12_txd_bit_counter As Byte
    Dim Rfm12_txd_byte_len As Byte
    Dim Rfm12_txd_byte As Byte
    Dim Rfm12_txd_string_1x As String * 1
    
    Dim Bit_counter As Byte
    Dim Init_counter As Byte
    Dim Bit_out As Integer
    Dim Spi_out As Word
    Dim Spi_in As Word
    
    Dim Tx_rfm12_ready As Bit : Tx_rfm12_ready = 0
    
    Dim Rgit_ffit As Bit
    Dim Por As Bit
    Dim Rug_ffov As Bit
    Dim Wkup As Bit
    Dim Ext As Bit
    Dim Lbd As Bit
    
    Dim Empfang_status As Byte : Empfang_status = 0
    Dim Sende_status As Byte : Sende_status = 0
    
    '--------------------------------------------------------------------------------------------------  config
    
    Config Int0 = Falling
    Config Timer1 = Timer , Prescale = 256
    
    '--------------------------------------------------------------------------------------------------  output
    
    Led Alias Portb.0 : Ddrb.0 = 1 : Portb.0 = 1
    Rfm12_cs Alias Portb.2 : Ddrb.2 = 1 : Portb.2 = 1
    Sdi Alias Portb.3 : Ddrb.3 = 1 : Portb.3 = 1
    Sck Alias Portb.5 : Ddrb.5 = 1 : Portb.5 = 0
    
    '--------------------------------------------------------------------------------------------------  input
    
    Sdo Alias Pinb.4 : Ddrb.4 = 0 : Portb.4 = 1
    Taster Alias Pind.7 : Ddrd.7 = 0 : Portd.7 = 1              'pullup portd.7
    Ddrd.2 = 0 : Portd.2 = 1
    
    '--------------------------------------------------------------------------------------------------  Starteinstellungen
    
    Print "Start"
    
    Gosub Rfm12_init
    
    On Urxc Usart_receive_complete_ir
    On Utxc Usart_transmit_complete_ir
    On Udre Usart_data_register_empty_ir
    
    Enable Urxc
    Enable Utxc
    Disable Udre
    
    On Int0 Isr_int0
    Enable Int0
    
    On Timer1 Timer1_isr
    Enable Timer1
    Timer1 = 34285
    
    Enable Interrupts
    
    Empfang_status = 0
    Sende_status = 0
    
    Rfm12_txd_string = "Ready" + Chr(13)
    Rfm12_rxd_string = ""
    
    Rfm12_txd_bit_counter = 0
    Gosub Send_rfm12
    Waitms 200
    Empfang_status = 1
    
    '##################################################################################################################   Hauptschleife
    
    Do
    
    If Rfm12_txd_string <> "" Then
             Rfm12_txd_bit_counter = 0
             Gosub Send_rfm12
             Waitms 200
             Rfm12_txd_string = ""
             Empfang_status = 1
    End If
    
    
    If Empfang_status = 1 Then                                  '  Empfang freigegeben
             Rfm12_rxd_bit_counter = 0
             Spi_out = &H82C8
             Gosub Spi_trans
             Spi_out = &HCA83
             Gosub Spi_trans
             Empfang_status = 2
             Enable Int0
    End If
    
    If Daten_empfangen = 1 Then                                 ' Daten Empfangen
             Spi_out = &H8208
             Gosub Spi_trans
    
             Print Rfm12_rxd_string;
    
             Rfm12_rxd_string = ""
             Rfm12_rxd_bit_counter = 0
             Daten_empfangen = 0
    
             Enable Int0
             Empfang_status = 1
    End If
    
    If Buffer <> "" Then Gosub Rxd_input_auswerten:
    
    
    Loop
    '##################################################################################################################   timer0_isr
    Timer1_isr:
    Timer1 = 34285
    
    Incr Sek_timer
    
    If Sek_timer = 60 Then
          Rfm12_txd_string = "M1_M2_XXXX_XXXX" + Chr(13)
          Toggle Led
          Sek_timer = 0
    End If
    
    Return
    '##################################################################################################################   INT0
    
    Isr_int0:
    '------------------------------------------------------------------------------------------------------------------
                                                                                                       'Statusregister lesen
    Spi_out = &H0000
    Gosub Spi_trans
    
    Rgit_ffit = Spi_in.15
    Por = Spi_in.14
    Rug_ffov = Spi_in.13
    Wkup = Spi_in.12
    Ext = Spi_in.11
    Lbd = Spi_in.10
    
    '-----------------------------------------------------------------------------------------------------------------
    
    If Rgit_ffit = 1 And Empfang_status = 2 Then
    
       Incr Rfm12_rxd_bit_counter
       Spi_out = &HB000
       Gosub Spi_trans
    
       If Rfm12_rxd_bit_counter < 50 Then
    
             Rfm12_rxd_byte = Spi_in
             Rfm12_rxd_string = Rfm12_rxd_string + Chr(rfm12_rxd_byte)
    
             If Rfm12_rxd_byte = 13 Then
                Daten_empfangen = 1
                Disable Int0
             End If
       End If
    
    End If
    
    If Pind.2 = 0 Then Print Bin(spi_in)
    
    Return
    
    '##################################################################################################################   rfm12_tx_ready
    Rfm12_tx_ready:
    
      Rfm12_cs = 0
      Do
      Loop Until Sdo = 1
    
    Return
    '##################################################################################################################   Send_rfm12
    
    Send_rfm12:
    
      Rfm12_txd_byte_len = Len(rfm12_txd_string)
    
      If Rfm12_txd_byte_len = 0 Then Return
    
      Disable Int0
    
      Spi_out = &H0000
      Gosub Spi_trans
    
      Spi_out = &HB8AA
      Gosub Spi_trans
    
      Spi_out = &HB8AA
      Gosub Spi_trans
    
      Spi_out = &H8239
      Gosub Spi_trans
      Gosub Rfm12_tx_ready
    
      Spi_out = &HB82D
      Gosub Spi_trans
      Gosub Rfm12_tx_ready
    
      Spi_out = &HB8D4
      Gosub Spi_trans
      Gosub Rfm12_tx_ready
    
      For Rfm12_txd_bit_counter = 1 To Rfm12_txd_byte_len
        Rfm12_txd_string_1x = Mid(rfm12_txd_string , Rfm12_txd_bit_counter , 1 )
        Rfm12_txd_byte = Rfm12_txd_string_1x
        Spi_out = &HB800 + Rfm12_txd_byte
        Gosub Spi_trans
        Gosub Rfm12_tx_ready
      Next Rfm12_txd_bit_counter
    
      Spi_out = &HB8AA
      Gosub Spi_trans
      Gosub Rfm12_tx_ready
    
      Spi_out = &HB8AA
      Gosub Spi_trans
      Gosub Rfm12_tx_ready
    
      Sende_status = 3
    
      Spi_out = &H8208
      Gosub Spi_trans
    
      Spi_out = &HB8AA
      Gosub Spi_trans
    
      Spi_out = &H0000
      Gosub Spi_trans
    
    Return
    '##################################################################################################################   spi_trans
    Spi_trans:
    
    Rfm12_cs = 0
    Spi_in = 0
    
       For Bit_counter = 1 To 16
          Bit_out = Spi_out And &H8000
          If Bit_out = 0 Then
             Sdi = 0
          Else
             Sdi = 1
          End If
             Spi_out = Spi_out * 2
             Spi_in = Spi_in * 2
             Spi_in = Spi_in + Sdo
             Sck = 1
          Waitus 5
             Sck = 0
       Next Bit_counter
    
    Rfm12_cs = 1
    
    Return
    
    '##################################################################################################################   rfm12_init
    Rfm12_init:
    
    Waitms 200
    
    For Init_counter = 1 To 12
    
       Select Case Init_counter
           Case 1 :
                   'Spi_out = &H80E7                             '868 mhz
                   Spi_out = &H80D7                             '433 mhz
          Case 2 : Spi_out = &H82D9
          Case 3 : Spi_out = &HA67C
          Case 4 : Spi_out = &HC6A4
          Case 5 : Spi_out = &H94C0
          Case 6 : Spi_out = &HC2AC
          Case 7 : Spi_out = &HCA81
          Case 8 : Spi_out = &HC483
          Case 9 : Spi_out = &H9827
          Case 10 : Spi_out = &HE000
          Case 11 : Spi_out = &HC800
          Case 12 : Spi_out = &HC000
    
    
       End Select
    
          Gosub Spi_trans
          Waitms 100
    
    Next Init_counter
    
    
    Return
    
    '##################################################################################################################     Rxd_input_auswerten
    
    Rxd_input_auswerten:
    
    Buffer = Ucase(rxd_buffer)
    Buffer_len = Len(buffer)
    Split_buffer_1 = Mid(buffer , 2 , 3)
    
    If Split_buffer_1 = "TXD" Then
    
          Rfm12_txd_string = Buffer + Chr(13)
    
          Spi_out = &H8208
          Gosub Spi_trans
    
    
          Txd_buffer = "sende :" + Buffer + Chr(13)
    
          Rfm12_txd_bit_counter = 0
          Gosub Send_rfm12
          'Waitms 200
          Empfang_status = 1
    
          Rfm12_txd_string = ""
    
       Else
    
          Split_buffer_2 = Mid(buffer , 6 , Buffer_len)
          Buffer_wert = Val(split_buffer_2)
    
    End If
    
    Select Case Split_buffer_1
    
       Case "SPI" :
                      Spi_out = Buffer_wert
                      Gosub Spi_trans
                      Txd_buffer = "OK_" + Hex(buffer_wert) + Chr(13)
    
       Case "STA" :
                      Spi_out = Buffer_wert
                      Gosub Spi_trans
                      Txd_buffer = Bin(spi_in) + Chr(13)
    
       Case "INI" :
                      Gosub Rfm12_init
                      Txd_buffer = "INIT" + Chr(13)
    
    End Select
    
    
    
    If Txd_buffer = "" Then Txd_buffer = "<ERROR" + Chr(13)
    Txd_len = Len(txd_buffer)
    Txd_byte_counter = 0
    Enable Udre
    Buffer = ""
    Return
    
    '###############################################################################    USART Receive Complete (Urxc)
    Usart_receive_complete_ir:
    
    push r12
    push r13
    push r14
    push r15
    
    Rxd_byte = Udr
    
    If Rxd_byte = Sync_byte And Startbit = 0 Then
                Startbit = 1
                Rxd_buffer = ""
                Rxd_in_counter = 0
    End If
    
    If Startbit = 1 Then
    
                Incr Rxd_in_counter
    
                If Rxd_byte <> 13 Then
                         If Rxd_in_counter < 30 Then
                               Rxd_buffer = Rxd_buffer + Chr(rxd_byte)
                         End If
                   Else
                         Buffer = Rxd_buffer
                         Disable Urxc
                         Startbit = 0
    
                End If
    End If
    
    pop r15
    pop r14
    pop r13
    pop r12
    
    Return
    
    '###############################################################################    USART Data Register Empty (Udre)
    Usart_data_register_empty_ir:
    
    push r12
    push r13
    push r14
    push r15
    
    If Txd_byte_counter < Txd_len Then
          Txd_byte_counter = Txd_byte_counter + 1
          Txd_string = Mid(txd_buffer , Txd_byte_counter , 1)
          Txd_byte = Txd_string
          Udr = Txd_byte
      Else
          Txd_byte_counter = 0
          Txd_len = 0
          Txd_buffer = ""
          Disable Udre
    End If
    
    pop r15
    pop r14
    pop r13
    pop r12
    
    Return
    '###############################################################################    Usart Transmit Complete (Utxc)
    Usart_transmit_complete_ir:
          Enable Urxc                                           'enable Empfang
    Return
    Angehängte Dateien Angehängte Dateien

Seite 2 von 2 ErsteErste 12

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • Anhänge hochladen: Nein
  • Beiträge bearbeiten: Nein
  •  

Labornetzteil AliExpress