Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

No valid Zero in slave side by UART micor communications

Status
Not open for further replies.

soheil_sa

Newbie level 1
Joined
Oct 2, 2015
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
10
I have some problem with UART communication bettwin two AVR micro-controller,I am using Microbasci For AVR and two side code are here:

***Transmitter Side:***
Code:
    program MyProject
    
    
    ''symbol Key0 = PORTB.0
    ''symbol Key1 = PORTB.1
    symbol MYDELAY =  delay_ms(100000)
    dim uart_rd,counter,error_,error,cnt_while,error1 as byte
    
    dim kp, cnt, oldstate,retn as byte
        txt as string[7]
    
    ''module MyProject
    ''dim keypadPort as byte at PORTB
    ''dim keypadPort_Direction as byte at DDRB
    
    ' End Keypad module connections
    ''*************************************
    
    
    ''***********************************
    
    dim LCD_RS as sbit  at PORTC5_bit
    ''Lcdpin = Pin , Db4 = Pinc.3 , Db5 = Pinc.2 , Db6 = Pinc.1 , Db7 = Pinc.0 , Rs = Pinc.5 , E = Pinc.4
    dim LCD_EN as sbit  at PORTC4_bit
    dim LCD_D4 as sbit  at PORTC3_bit
    dim LCD_D5 as sbit  at PORTC2_bit
    dim LCD_D6 as sbit  at PORTC1_bit
    dim LCD_D7 as sbit  at PORTC0_bit
    
    dim LCD_RS_Direction as sbit at DDC5_bit
    dim LCD_EN_Direction as sbit at DDC4_bit
    dim LCD_D4_Direction as sbit at DDC3_bit
    dim LCD_D5_Direction as sbit at DDC2_bit
    dim LCD_D6_Direction as sbit at DDC1_bit
    dim LCD_D7_Direction as sbit at DDC0_bit
    ''***************************************************************ãÊÛíÑåÇ************************************************
    Dim Sync As Byte                                            '/ / Synchro Signal
    Dim Raddr As Byte
    Dim Ledoff As Byte
    Dim Ledon As Byte
    Dim Parity As Byte
    Dim Code1 As Byte
    Dim Code2 As Byte
    Dim Code_share As Byte
    Dim A1 As String [4]
    Dim A2 As String [4]
    
    
    '' ***********************************************************lcd1*******************************************
    ' End Lcd module connections
      ''dim error as byte
    sub procedure Initialize ()
       DDB0_bit = 0                    ' set portd pin0 as Input pin for ufa fountain
       DDB1_bit = 0                    ' set portd pin0 as Input pin for ufa fountain
       DDB3_bit = 0                    ' set portd pin0 as Input pin for ufa fountain
       DDB4_bit = 0                    ' set portd pin0 as Input pin for ufa fountain
       A1= "OK"
       Code1 = 100
       Code2 = 200
       Sync = 255
       Raddr = 115
       Ledon = 77
       Parity = Raddr + Ledon
       Ledoff = 3
       cnt=0
       cnt_while=0
    
       SREG_I_bit = 0                   ' Interrupt disable
       SREG_I_bit = 1                   ' Interrupt disable
       Delay_ms(100)                            ' Wait for UART module to stabilize
       ''oldstate = 0
       ''cnt = 0                                ' Reset counter
      '' Keypad_Init()
    
    end sub
    
    
    sub procedure UART_ini ()
       error1 = Soft_UART_Init(PORTD,0,1,9600,0)        ''// Initialize Soft UART at 9600 bps
        if (error1 = 0) then '' UART Working
          Lcd_Out(1,1, " UART 9600 successfull")
           WordToStr(error1, txt)              ' Transform counter value to string
           Lcd_Out(2,6, txt)
           Delay_ms(100)
    
    
         else
          Lcd_Out(1,1, " Fail ini UART:")
          WordToStr(error1, txt)              ' Transform counter value to string
          Lcd_Out(2,6, txt)
          Delay_ms(100)
        end if
       ''UART1_Init(1200)                        ' Initialize UART module at 9600 bps
    
    end sub
    
    sub procedure UART_ini_simple()
    UART1_Init(9600)
    UART1_Init_Advanced(9600, _UART_EVENPARITY, _UART_TWO_STOPBITS)
    
    end sub
    sub procedure LCD_P1 ()
    
    
        Lcd_Init()                        ' Initialize LCD
        Lcd_Cmd(_LCD_CLEAR)               ' Clear display
        Lcd_Cmd(_LCD_CURSOR_OFF)          ' Cursor off
        LCD_Out(1,8,A1)                 ' Write text in first row
        ''LCD_Out(2,3,txt2)
    
    end sub
    
    sub procedure PRESSKEY1 ()
        kp = 0                             ' Reset key code variable
    
        ' Wait for key to be pressed and released
        while ( kp = 0 )
          kp = Keypad_Key_Click()          ' Store key code in kp variable
        wend
        ' Prepare value for output, transform key to it"s ASCII value
        select case kp
          'case 10: kp = 42   ' "*"        ' Uncomment this block for keypad4x3
          'case 11: kp = 48   ' "0"
          'case 12: kp = 35   ' "#"
          'default: kp += 48
    
        case 1
          kp = 49  ' 1               ' Uncomment this block for keypad4x4
        case 2
          kp = 50  ' 2
        case 3
          kp = 51  ' 3
        case 4
          kp = 65  ' A
        case 5
          kp = 52  ' 4
        case 6
          kp = 53  ' 5
        case 7
          kp = 54  ' 6
        case 8
          kp = 66  ' B
        case 9
          kp = 55  ' 7
        case 10
          kp = 56  ' 8
        case 11
          kp = 57  ' 9
        case 12
          kp = 67  ' C
        case 13
          kp = 42  ' *
        case 14
          kp = 48  ' 0
        case 15
          kp = 35  ' #
        case 16
          kp = 68  ' D
    
        end select
    
        if (kp <> oldstate) then         ' Pressed key differs from previous
          cnt = 1
          oldstate = kp
        else                             ' Pressed key is same as previous
          Inc(cnt)
        end if
        Lcd_Chr(1, 10, kp)               ' Print key ASCII value on LCD
    
        if (cnt = 255) then              ' If counter varialble overflow
          cnt = 0
          Lcd_Out(2, 10, "     ")
        end if
    
        WordToStr(cnt, txt)              ' Transform counter value to string
        Lcd_Out(2, 10, txt)              ' Display counter value on LCD
    
    
    
    end sub
    sub procedure PRESSKEY3 ()
    
    oldstate = 0
    retn=0                                      ' oldstate initial value
    cnt_while=0
            while cnt<> 2
            if (PINB0_bit=1) then
                                   ' detect one-to-zero transition
             cnt_while=1
             LCD_Out(1,1,"key b0 : is pressd")
             inc(cnt)
             retn=cnt                            ' invert PORTC
            oldstate = 0                         ' update flag
    
                WordToStr(cnt, txt)              ' Transform counter value to string
                Lcd_Out(2, 10, txt)              ' Display counter value on LCD
                Delay_ms(100)                  ' Wait for  module to stabilize
          end if
      wend
    end sub
    sub procedure PRESSKEY2 ()
    oldstate = 0  
    retn=0                                      ' oldstate initial value
    cnt_while=0
            while cnt<> 2
            if  Button(PINB, 0, 1, 0) then
            oldstate = 1                                  ' update flag
          end if
          if (oldstate and Button(PINB, 0, 1, 1)) then    ' detect one-to-zero transition
             cnt_while=1
             LCD_Out(1,1,"key b0 : is pressd")
             inc(cnt) 
             retn=cnt                            ' invert PORTC
            oldstate = 0                         ' update flag
    
                WordToStr(cnt, txt)              ' Transform counter value to string
                Lcd_Out(2, 10, txt)              ' Display counter value on LCD
          end if
      wend
    end sub
    ''dim Send_Button as sbit at PIND3_bit
    ''dim Send_Button_Direction as sbit at DDD3_bit
    
    ''dim rxBuff as string[16]         ' Buffer string for storing data
    ''dim rxCnt as byte                ' Counter for data writen in buffer string
    ''dim Received as byte             ' Received data flag
    
    ' Interrupt routine
    
      ' MCU initialization
    ''sub procedure MCU_Init()
      ' Initialize global variables
     '' rxCnt = 0
      ''Received = 0
    
      ''Send_Button_Direction = 0      ' Set PORTD.B3 pin as input
    
      ''UART1_Init(19200)              ' Initialize UART module at 19200 bps
      ''Delay_ms(100)                  ' Wait for UART module to stabilize
    
      ''cd_Init()                     ' Initialize LCD display
      ''Lcd_Cmd(_LCD_CURSOR_OFF)       ' Cursor off
      ''Lcd_Cmd(_LCD_CLEAR)            ' Clear display
    
      ''RXCIE_bit = 1                  ' Turn ON interrupt on UART1 receive
      ''SREG_I_bit = 1                 ' Enable Interrupts
    ''''end sub
    sub  procedure Uart_send()
         cnt=0
         error=0
    ''     error = Soft_UART_Init(PORTD, 0, 1, 9600, 0)
    
    ''     error_ = Soft_UART_Init(PORTD,0,1,9600,0)      ' Initialize Soft UART at 14400 bps
        if (error > 0) then
           ''PORTB = error_                       ' Signalize Init error
           while TRUE
             Lcd_Cmd(_LCD_CLEAR)               ' Clear display
            Lcd_Cmd(_LCD_CURSOR_OFF)
            Lcd_Out(2,1,"Error=")
            Lcd_Out(2, 3, txt)
            Delay_ms(100)                              ' Stop program
           wend
        end if
        Delay_ms(100)
    
    
         Lcd_Cmd(_LCD_CLEAR)               ' Clear display
         Lcd_Cmd(_LCD_CURSOR_OFF)
         Lcd_Out(1,1,"Waiting For UART")
         Lcd_Out(2,1,"To Be Pressed")
         Delay_ms(100)
         while TRUE
    
         WordToStr(error, txt)
    
        '' if(Button(PINB, 1, 1, 0)) then           ' If PORTD.B1 is pressed :
        if (PINB1_bit=0) then
            LCD_P1 ()
            Lcd_Cmd(_LCD_CLEAR)               ' Clear display
            Lcd_Cmd(_LCD_CURSOR_OFF)
            Lcd_Out(2,1,"Er:")
            Lcd_Out(2, 3, txt)
            Delay_ms(100)
            Lcd_Cmd(_LCD_CLEAR)
            inc(cnt)
            retn=cnt                            ' invert PORTC
    
    
           WordToStr(cnt, txt)              ' Transform counter value to string
    
           Lcd_Out(2, 11, txt) Delay_ms(250)
           
           retn = 255
           ''UART1_Write(cnt)
           
           UART1_Write_Text("EchoTest") txt="EchoTest"      '  send text string
    
    
           ''UART1_Write_Text(txt)
           Delay_ms(250)      '  wait for 250ms
           if  (UART_Tx_Idle() <> 0)    then
    
           
                  ''WordToStr(retn, txt)
                  Lcd_Out(1,1,"send Done:")
                  Lcd_Out(2, 1, txt)
                  ''UART1_Write($AA)
              Delay_ms(250)      '  wait for 250ms
           end if
         end if
    
         wend
    end sub
    sub procedure Uart_send2()
           while TRUE
           if(Button(PINB, 1, 1, 1)) then           ' If PORTD.B3 is pressed :
            LCD_P1 ()
            inc(cnt)
             retn=cnt                            ' invert PORTC
    
    
                WordToStr(cnt, txt)              ' Transform counter value to string
                Lcd_Out(2, 10, txt)
                
               error_ = Soft_UART_Init(PORTD,0,1,9600,0)      ' Initialize Soft UART at 14400 bps
                if (error_ > 0) then
                     PORTB = error_                       ' Signalize Init error
                     while TRUE
                      Lcd_Out(2, 10, "Erorre")
                      nop                              ' Stop program
                     wend
               end if
               Delay_ms(100)
    
              for counter = "z" to "A" step -1       ' Send bytes from 'z' downto 'A'
               Soft_UART_Write(counter)
               Lcd_Out(2,1,"Uart:")
               WordToStr(counter, txt)
               Lcd_Out(2,7,txt)
               Delay_ms(100)
              next counter
          end if
          wend
    end sub
    
    
    main:
      ''MCU_Init()                            ' Initialize the MCU
      ''Lcd_Out(1, 1, "tRFclick example")     ' Display starting message on the Lcd
    
    
    ' Initialize Software UART communication on pins Rx, Tx, at 14400 bps
      '' error = Soft_UART_Init(PORTB, 1, 2, 9600, 0)
    
     '' while TRUE
        ''if(Button(PIND, 3, 1, 1)) then      ' If PORTD.B3 is pressed :
         '' UART1_Write_Text("EchoTest")      '  send text string
         '' UART1_Write(13)
          ''Delay_ms(250)                     '  wait for 250ms
        ''end if
    
       '' if(Received) then                   ' If data is received via UART :
          ''Lcd_cmd(_LCD_SECOND_ROW)          '   set cursor in the second row
          ''Lcd_Out(2, 1, "                ") '   clear second row
          ''Lcd_Out(2, 1, rxBuff)             '   display the received data in the second row
         '' Received = 0                      '   clear received data flag
       '' end if
     '' wend
    Lcd_Init()                        ' Initialize LCD
    Lcd_Cmd(_LCD_CLEAR)               ' Clear display
    Lcd_Cmd(_LCD_CURSOR_OFF)          ' Cursor off
    Initialize ()
    ''UART_ini ()
    UART_ini_simple()
    while TRUE
    
    
     ''MYDELAY
    ''oldstate = 0
    ''cnt = 0
     ''oldstate = 0
      ''cnt = 0                                ' Reset counter
      ''Keypad_Init()                          ' Initialize Keypad
      LCD_P1 ()
     PRESSKEY3 ()
       ''UART1_Init(19200)                        ' Initialize UART module at 9600 bps
      Delay_ms(100)                            ' Wait for UART module to stabilize
       Uart_send()
      ''while TRUE                               ' Endless loop
       ''   if (UART1_Data_Ready() <> 0) then    ' If data is received,
        ''      uart_rd = UART1_Read()           ' read the received data,
        ''      UART1_Write(uart_rd)             ' and send data via UART
        ''  end if
     '' wend
    
     
    
    
    
    
     wend
    
     
    end.

***Resiver side:***
Code:
    program resiver
    
    ''symbol Key0 = PORTB.0
    ''symbol Key1 = PORTB.1
    symbol MYDELAY =  delay_ms(100000)
    dim uart_rd,counter,error_,receive,error,error1,data1 ,error2_ as byte
    
    dim kp, cnt, oldstate,retn as byte
        txt as string[7]
        txt2 as string[7]
        txt_inin as string[7]
    
    ''module MyProject
    ''dim keypadPort as byte at PORTB
    ''dim keypadPort_Direction as byte at DDRB
    
    ' End Keypad module connections
    ''*************************************
    
    
    ''***********************************
    
    dim LCD_RS as sbit  at PORTC5_bit
    ''Lcdpin = Pin , Db4 = Pinc.3 , Db5 = Pinc.2 , Db6 = Pinc.1 , Db7 = Pinc.0 , Rs = Pinc.5 , E = Pinc.4
    dim LCD_EN as sbit  at PORTC4_bit
    dim LCD_D4 as sbit  at PORTC3_bit
    dim LCD_D5 as sbit  at PORTC2_bit
    dim LCD_D6 as sbit  at PORTC1_bit
    dim LCD_D7 as sbit  at PORTC0_bit
    
    dim LCD_RS_Direction as sbit at DDC5_bit
    dim LCD_EN_Direction as sbit at DDC4_bit
    dim LCD_D4_Direction as sbit at DDC3_bit
    dim LCD_D5_Direction as sbit at DDC2_bit
    dim LCD_D6_Direction as sbit at DDC1_bit
    dim LCD_D7_Direction as sbit at DDC0_bit
    ''***************************************************************ãÊÛíÑåÇ************************************************
    Dim Sync As Byte                                            '/ / Synchro Signal
    Dim Raddr As Byte
    Dim Ledoff As Byte
    Dim Ledon As Byte
    Dim Parity As Byte
    Dim Code1 As Byte
    Dim Code2 As Byte
    Dim Code_share As Byte
    Dim A1 As String [4]
    Dim output As String [4]
    
    
    '' ***********************************************************lcd1*******************************************
    ' End Lcd module connections
      ''dim error as byte
    sub procedure Initialize ()
       DDB0_bit = 0                    ' set portd pin0 as Input pin for ufa fountain
       DDB1_bit = 0                    ' set portd pin0 as Input pin for ufa fountain
       DDB3_bit = 0                    ' set portd pin0 as Input pin for ufa fountain
       DDB4_bit = 0                    ' set portd pin0 as Input pin for ufa fountain
       A1= "OK"
       Code1 = 100
       Code2 = 200
       Sync = 255
       Raddr = 115
       Ledon = 77
       Parity = Raddr + Ledon
       Ledoff = 3
       cnt=0
    
       Delay_ms(100)  
       LCD_Out(1,8,A1)                           ' Wait for UART module to stabilize
      '' error = Soft_UART_Init(PORTD, 0, 1, 9600, 0)
       ''oldstate = 0
       ''cnt = 0                                ' Reset counter
      '' Keypad_Init()
    
    end sub
    sub procedure UART_ini ()
       error1 = Soft_UART_Init(PORTD,0,1,9600,0)        ''// Initialize Soft UART at 9600 bps
        if (error1 = 0) then '' UART Working
          Lcd_Out(1,1, " UART 9600 successfull  ")
           WordToStr(error1, txt_inin)              ' Transform counter value to string
           Lcd_Out(2,6, txt_inin)
           Delay_ms(1100)
    
    
         else
          Lcd_Out(1,1, " Fail ini UART:")
          WordToStr(error1, txt)              ' Transform counter value to string
          Lcd_Out(2,6, txt)
          Delay_ms(1100)
        end if
       ''UART1_Init(1200)                        ' Initialize UART module at 9600 bps
    
    end sub
    sub procedure UART_ini_simple()
    UART1_Init(9600)
    UART1_Init_Advanced(9600, _UART_EVENPARITY, _UART_TWO_STOPBITS)
    
    end sub
    
    sub procedure LCD_P1 ()
    
    
        Lcd_Init()                        ' Initialize LCD
        Lcd_Cmd(_LCD_CLEAR)               ' Clear display
        Lcd_Cmd(_LCD_CURSOR_OFF)          ' Cursor off
        LCD_Out(1,8,A1)                 ' Write text in first row
        ''LCD_Out(2,3,txt2)
    
    end sub
    
    sub procedure PRESSKEY1 ()
        kp = 0                             ' Reset key code variable
    
        ' Wait for key to be pressed and released
        while ( kp = 0 )
          kp = Keypad_Key_Click()          ' Store key code in kp variable
        wend
        ' Prepare value for output, transform key to it"s ASCII value
        select case kp
          'case 10: kp = 42   ' "*"        ' Uncomment this block for keypad4x3
          'case 11: kp = 48   ' "0"
          'case 12: kp = 35   ' "#"
          'default: kp += 48
    
        case 1
          kp = 49  ' 1               ' Uncomment this block for keypad4x4
        case 2
          kp = 50  ' 2
        case 3
          kp = 51  ' 3
        case 4
          kp = 65  ' A
        case 5
          kp = 52  ' 4
        case 6
          kp = 53  ' 5
        case 7
          kp = 54  ' 6
        case 8
          kp = 66  ' B
        case 9
          kp = 55  ' 7
        case 10
          kp = 56  ' 8
        case 11
          kp = 57  ' 9
        case 12
          kp = 67  ' C
        case 13
          kp = 42  ' *
        case 14
          kp = 48  ' 0
        case 15
          kp = 35  ' #
        case 16
          kp = 68  ' D
    
        end select
    
        if (kp <> oldstate) then         ' Pressed key differs from previous
          cnt = 1
          oldstate = kp
        else                             ' Pressed key is same as previous
          Inc(cnt)
        end if
        Lcd_Chr(1, 10, kp)               ' Print key ASCII value on LCD
    
        if (cnt = 255) then              ' If counter varialble overflow
          cnt = 0
          Lcd_Out(2, 10, "     ")
        end if
    
        WordToStr(cnt, txt)              ' Transform counter value to string
        Lcd_Out(2, 10, txt)              ' Display counter value on LCD
    
    
    
    end sub
    sub procedure PRESSKEY2 ()
    oldstate = 0
    retn=0                                      ' oldstate initial value
    
      while retn <> 3
          if (Button(PINB, 0, 1, 1) <> 0) then            ' detect logical one
            oldstate = 1                                  ' update flag
          end if
          if (oldstate and Button(PINB, 0, 1, 0)) then    ' detect one-to-zero transition
             LCD_Out(1,1,"key b0 : is pressd")
             inc(cnt)
             retn=cnt                            ' invert PORTC
            oldstate = 0                         ' update flag
    
                WordToStr(cnt, txt)              ' Transform counter value to string
                Lcd_Out(2, 10, txt)              ' Display counter value on LCD
          end if
      wend
    end sub
    ''dim Send_Button as sbit at PIND3_bit
    ''dim Send_Button_Direction as sbit at DDD3_bit
    
    ''dim rxBuff as string[16]         ' Buffer string for storing data
    ''dim rxCnt as byte                ' Counter for data writen in buffer string
    ''dim Received as byte             ' Received data flag
    
    ' Interrupt routine
    
      ' MCU initialization
    ''sub procedure MCU_Init()
      ' Initialize global variables
     '' rxCnt = 0
      ''Received = 0
    
      ''Send_Button_Direction = 0      ' Set PORTD.B3 pin as input
    
      ''UART1_Init(19200)              ' Initialize UART module at 19200 bps
      ''Delay_ms(100)                  ' Wait for UART module to stabilize
    
      ''cd_Init()                     ' Initialize LCD display
      ''Lcd_Cmd(_LCD_CURSOR_OFF)       ' Cursor off
      ''Lcd_Cmd(_LCD_CLEAR)            ' Clear display
    
      ''RXCIE_bit = 1                  ' Turn ON interrupt on UART1 receive
      ''SREG_I_bit = 1                 ' Enable Interrupts
    ''''end sub
    sub procedure UART_Read_simple()
        error = 1
        do
        error = Soft_UART_Init(PORTD, 0, 1, 9600, 0)
          receive = Soft_UART_Read(error)
          Lcd_Out(1, 1, "UART recived:")
                WordToStr(receive, txt2)
                UART_Write(receive)
                Lcd_Out(2, 3, txt2)
                inc(cnt)
                retn=cnt                            ' invert PORTC
                WordToStr(cnt, txt)              ' Transform counter value to string
                Lcd_Out(2, 10, txt)
                Delay_ms(100)
        loop until error = 0
    
    
    end sub
    sub  procedure Uart_res()
         cnt=0
         error=0
         while TRUE
    
    
         ''Lcd_Out(1, 1, "urt_first")
         if (UART_Data_Ready() <> 0)then         ' if data is received
                receive = UART1_Read()
    
    
                Lcd_Out(1, 1, "UART recived:")
                WordToStr(receive, txt2)
                UART_Write(receive)
                Lcd_Out(2, 3, txt2)
                inc(cnt)
                retn=cnt                            ' invert PORTC
                WordToStr(cnt, txt)              ' Transform counter value to string
                Lcd_Out(2, 10, txt)
                Delay_ms(100)
           retn = 0x1E
        '' UART_Read_Text(output, "OK", 10)  ' reads text until 'OK' is found
         ''UART_Write_Text(output)              ' sends back text
         end if
                       '  wait for 250ms
         wend
    end sub
    sub procedure Uart_Read_low()
    if (UART1_Data_Ready() <> 0) then  ' If data is received,
          uart_rd = UART1_Read()           ' read the received data,
    
        end if
    end sub
    sub procedure Uart_send2()
           while TRUE
           if(Button(PINB, 1, 1, 1)) then           ' If PORTD.B3 is pressed :
            LCD_P1 ()
            inc(cnt)
             retn=cnt                            ' invert PORTC
    
    
                WordToStr(cnt, txt)              ' Transform counter value to string
                Lcd_Out(2, 10, txt)
    
               ''error_ = Soft_UART_Init(PORTD,0,1,1200,0)      ' Initialize Soft UART at 14400 bps
                if (error_ > 0) then
                     PORTB = error_                       ' Signalize Init error
                     while TRUE
                      Lcd_Out(2, 10, "Erorre")
                      Delay_ms(1100)
                      nop                              ' Stop program
                     wend
               end if
               Delay_ms(100)
    
              for counter = "z" to "A" step -1       ' Send bytes from 'z' downto 'A'
               Soft_UART_Write(counter)
               Delay_ms(100)
              next counter
          end if
          wend
    end sub
    
    
    main:
      ''MCU_Init()                            ' Initialize the MCU
      ''Lcd_Out(1, 1, "tRFclick example")     ' Display starting message on the Lcd
    
    
    ' Initialize Software UART communication on pins Rx, Tx, at 14400 bps
    ''  error = Soft_UART_Init(PORTD, 0, 1, 9600, 0)
    
     '' while TRUE
        ''if(Button(PIND, 3, 1, 1)) then      ' If PORTD.B3 is pressed :
         '' UART1_Write_Text("EchoTest")      '  send text string             ' if data is received
          ''Delay_ms(250)                     '  wait for 250ms
        ''end if
    
       '' if(Received) then                   ' If data is received via UART :
          ''Lcd_cmd(_LCD_SECOND_ROW)          '   set cursor in the second row
          ''Lcd_Out(2, 1, "                ") '   clear second row
          ''Lcd_Out(2, 1, rxBuff)             '   display the received data in the second row
         '' Received = 0                      '   clear received data flag
       '' end if
     '' wend
    Lcd_Init()                        ' Initialize LCD
    Lcd_Cmd(_LCD_CLEAR)               ' Clear display
    Lcd_Cmd(_LCD_CURSOR_OFF)          ' Cursor off
    Initialize ()
    ''UART_ini ()
    UART_ini_simple()
    ' try Soft_UART_Read with blocking prevention mechanism
    
    
    while TRUE
       LCD_P1 ()
        UART_Read_simple()
       ''Uart_res()
    
      wend
    
    
    
    
    
    
    
    
    
    end.
    
    ' Declarations section
the problem is that when i send a string ("Echo Test") via UART from transmitter micro side,
I get only zero in receiver side.
The Proteus simulation is here:

**broken link removed**


and the whole side simulation and Proteus Schematic is found here:

29ncrcn.jpg


another question is from Proteus , because i could not see any signal from VIRTUAL TERMINAL in Proteus.





Please simulate the codes to see more about codes.
Thanks a lot for your attention.
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top