Issues sending and receiving data


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: Issues sending and receiving data

    .... also maybe.....
    PreAmble CON $A5
    debug PreAmble,$af,$c2,$b5,$ef,13,10
    PreAmble CON $A5


    ,$af,$c2,$b5,$ef,13,10 is equal to 175,194,181,239,13,10 .... so ... debug 165,175,194,181,239,13,10.... or debug HEX 165,175,194,181,239,13,10

    then.... Main:
    DEBUGIN 1000,timeoutlabel,[WAIT(165),DAT1,DAT2,DAT3]
    pause 3000
    or
    Main:
    DEBUGIN 1000,timeoutlabel,[WAIT(HEX $AF),$DAT1,$DAT2,$DAT3]
    pause 3000....
    have to know what exactly characters are sending and receiving... I would output to a serial terminal to see if what you are sending is what you think you are sending
    Last edited by amgen; - 29th October 2024 at 12:47.

  2. #2
    Join Date
    Jul 2024
    Posts
    35


    Did you find this post helpful? Yes | No

    Default Re: Issues sending and receiving data

    Greetings amgen,

    thanks for the help,

    This is the data sent from PIC #1 and captured with the analyzer:


    Code:
    
    
    Code:
    [00][A5][AF][C2][B5][EF][0D][0A]
    



    And this is the data sent from PIC #2 (when in timeoutlabel) and captured with the analyzer:


    Code:
    
     [4E][4E][BF][79][0D][0A][00]
    


  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Issues sending and receiving data

    your sending capture looks good. Handling the receive, the debug in may or may not filter how you want... play with that some because if receiving HEX, that is 2 bytes to make into 1 byte value of DAT etc... ???? ... can also dictate (if it is not the default) 2 digits for the hex... HEX2
    maybe.... DEBUGIN 1000,timeoutlabel,[WAIT("AF"),$DAT1,$DAT2,$DAT3].... or DEBUGIN 1000,timeoutlabel,[WAIT(HEX2 AF),$DAT1,$DAT2,$DAT3].... or DEBUGIN 1000,timeoutlabel,[WAIT(HEX2 "AF"),$DAT1,$DAT2,$DAT3]
    .
    .
    . Thought of 1 more thing.... add a temporary serout or debug and send to your capture or ser terminal 1 received character at a time to easily see what you are receiving
    Last edited by amgen; - 29th October 2024 at 15:08.

  4. #4
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,175


    Did you find this post helpful? Yes | No

    Default Re: Issues sending and receiving data

    I do not have that chip, so can you check if this code works please?

    Code:
    '****************************************************************'*  Name    : 16F1503_Receive.PBP                               *
    '*            PORTA.1 CONNECTED TO PORTA.2 ON SENDING PIC       *
    '****************************************************************
    '
    ;----[16F1503 Hardware Configuration]-------------------------------------------
    #IF __PROCESSOR__ = "16F1503"
      #DEFINE MCU_FOUND 1
    #CONFIG
    cfg1 = _FOSC_INTOSC           ; INTOSC oscillator: I/O function on CLKIN pin
    cfg1&= _WDTE_OFF              ; WDT disabled
    cfg1&= _PWRTE_OFF             ; PWRT disabled
    cfg1&= _MCLRE_OFF             ; MCLR/VPP pin function is digital input
    cfg1&= _CP_OFF                ; Program memory code protection is disabled
    cfg1&= _BOREN_OFF             ; Brown-out Reset disabled
    cfg1&= _CLKOUTEN_OFF          ; CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin
      __CONFIG _CONFIG1, cfg1
    
    
    cfg2 = _WRT_OFF               ; Write protection off
    cfg2&= _STVREN_OFF            ; Stack Overflow or Underflow will not cause a Reset
    cfg2&= _BORV_LO               ; Brown-out Reset Voltage (Vbor), low trip point selected.
    cfg2&= _LPBOR_OFF             ; Low-Power BOR is disabled
    cfg2&= _LVP_OFF               ; High-voltage on MCLR/VPP must be used for programming
      __CONFIG _CONFIG2, cfg2
    
    
    #ENDCONFIG
    
    
    #ENDIF
    
    
    ;----[Verify Configs have been specified for Selected Processor]----------------
    ;       Note: Only include this routine once, after all #CONFIG blocks
    #IFNDEF MCU_FOUND
      #ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]"
    #ENDIF
    
    
    '*****************************************************************************
    
    
    DEFINE OSC 16                               ' Let PBP clock speed will be 16MHz
    OSCCON = %01111011                          ' Use internal oscillator and set to 16MHz
    
    
    OPTION_REG.7 = 0                            ' Enable individual control of weak pull-ups
    WPUA.0 = 0                                  ' Disable weak pull-up on RA0
    WPUA.1 = 0                                  ' Disable weak pull-up on RA1
    WPUA.2 = 0                                  ' Disable weak pull-up on RA2
    WPUA.3 = 0                                  ' Disable weak pull-up on RA3
    WPUA.4 = 0                                  ' Disable weak pull-up on RA4
    WPUA.5 = 0                                  ' Disable weak pull-up on RA5
    
    
    DACCON0.7 = 0                               ' Disable DAC
    CM1CON0.7 = 0                               ' Disable comparator 1
    CM2CON0.7 = 0                               ' Disable comparator 2
    
    
    TRISA = %00001010                           ' Set RA1-RA3 as inputs
    TRISC = %00000000                           ' Set RC port as output
    
    
    '*****************************************************************************
    
    
    INCLUDE "ALLDIGITAL.pbp"
    DEFINE SHOWDIGITAL 1
    
    
    INCLUDE "DT_INTS-14.bas"     ' Base Interrupt System
    INCLUDE "ReEnterPBP.bas"     ' Include if using PBP interrupts
    
    
    INCLUDE "modedefs.bas" 
    
    
    DEFINE DEBUG_REG PORTA 			' Set Debug pin port
    DEFINE DEBUG_BIT 3				' Set Debug pin bit
    DEFINE DEBUG_BAUD 2400			' Set Debug baud rate 
    DEFINE DEBUG_MODE 0				' Set Debug mode: 0 = true, 1 = inverted
    
    
    DEFINE DEBUGIN_REG PORTA		' Set Debugin pin port 
    DEFINE DEBUGIN_BIT 1			' Set Debugin pin bit  
    DEFINE DEBUGIN_BAUD 2400		' Set Debugin baud rate (same as Debug baud) 
    DEFINE DEBUGIN_MODE 0			' Set Debugin mode: 0 = true, 1 = inverted  
    
    
    '*****************************************************************************
    ;____[ For 12F/16F only - Interrupt Context save locations]_________________
    ;-- Place a copy of these variables in your Main program -------------------
    ;--   The compiler will tell you which lines to un-comment                --
    ;--   Do Not un-comment these lines                                       --
    ;---------------------------------------------------------------------------
    ;wsave   VAR BYTE    $20     SYSTEM      ' location for W if in bank0
    ;wsave   VAR BYTE    $70     SYSTEM      ' alternate save location for W 
                                             ' if using $70, comment wsave1-3
    
    
    ' --- IF any of these three lines cause an error ?? ------------------------
    '       Comment them out to fix the problem ----
    ' -- Which variables are needed, depends on the Chip you are using -- 
    ;wsave1  VAR BYTE    $A0     SYSTEM      ' location for W if in bank1
    ;wsave2  VAR BYTE    $120    SYSTEM      ' location for W if in bank2
    ;wsave3  VAR BYTE    $1A0    SYSTEM      ' location for W if in bank3
    ' --------------------------------------------------------------------------
    'https://www.picbasic.co.uk/forum/showthread.php/3251-Instant-Interrupts-Revisited/page7?highlight=DT%27s+instant+interrupts
    'https://www.picbasic.co.uk/forum/showthread.php/3251-Instant-Interrupts-Revisited/page16?highlight=DT%27s+instant+interrupts
    'Open the DT_INTS-14.bas file and comment out the wsave lines. 
    'The 675 doesn't have any usable RAM in banks 1,2 or 3
    
    
    '*****************************************************************************
    
    
    INTCON.3=1
    IOCAP.1=1 	     'POSITIVE EDGE @ A1 ON
    IOCAN=%0		 'NEGATIVE EDGE OFF
    
    
    'page 106
    
    
    '*****************************************************************************
    '---[INT - interrupt handler]---------------------------------------------------
    'ASM
    'INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
    '        INT_Handler  IOC_INT,    _IOCinterrupts,    PBP,  yes
    'endm
    'INT_CREATE               ; Creates the interrupt processor
    'ENDASM
    '
    '
    '@ INT_ENABLE IOC_INT
    
    
    '*****************************************************************************
    'PORTS & PINS 
    	
    INTLED	    VAR		PORTC.3		'INTERRUPT LED		
    MESLED	    VAR		PORTC.4		'MESSAGE LED
    
    
    '*****************************************************************************
    
    
    DAT1        VAR     BYTE	'
    DAT2        VAR     BYTE	'
    DAT3        VAR     BYTE	'
    CT			VAR		BYTE	'
    
    
    '*****************************************************************************
    INIT:
    
    
    PORTC=%000000
    
    
    GOTO START
    
    
    '------------------------------------------------------------------------------
    START:
    
    
    LOW INTLED
    LOW MESLED
    
    DEBUGIN 1000,timeoutlabel,[WAIT($af),DAT1,DAT2,DAT3]
    
    GOTO START
    
    timeoutlabel:
        low INTLED
    
    
        HIGH MESLED
        debug "Bad data",13,10 'Message confirming bad reception
    
        pause 1000
        low MESLED
    goto START
    
    
    ''------------------------------------------------------------------------------
    'IOCinterrupts:
    
    
    '@   INT_DISABLE IOC_INT 
    
    
    'HIGH INTLED
    
    
    'PAUSE 500
    
    
    'DEBUGIN 1000,timeoutlabel,[WAIT($af),DAT1,DAT2,DAT3]
    
    
    'PAUSE 200
    
    
    'pause 500
    
    
    'low INTLED
    
    
    'PAUSE 500
    
    
    'IF DAT1=$c2 THEN
    'GOTO PROGSEL
    'ENDIF
    
    
    ''RETURN TO PROGRAM
    'IOCAF=%0
    '@ INT_ENABLE IOC_INT
    '@ INT_RETURN
    
    
    ';-------------------------------------------------------------------------------
    'timeoutlabel:
    
    
    'low INTLED
    
    
    'HIGH MESLED
    'debug DEC 99,DAT1,DAT2,DAT3,13,10 'Message confirming bad reception
    
    
    'pause 1000
    'low MESLED
    
    
    ''RETURN TO PROGRAM
    'IOCAF=%0
    '@ INT_ENABLE IOC_INT
    '@ INT_RETURN
    
    
    ;-------------------------------------------------------------------------------
    PROGSEL
    
    
    debug DEC 09,DAT1,DAT2,DAT3,13,10 'Message confirming reception
    
    
    for ct=0 to 10
    toggle INTLED
    toggle MESLED
    pause 500
    next ct
    
    
    
    
    'RETURN TO PROGRAM
    'IOCAF=%0
    '@ INT_ENABLE IOC_INT
    '@ INT_RETURN
    ;-------------------------------------------------------------------------------
    Ioannis

Similar Threads

  1. SERIN2 Receiving Wrong Data
    By rsocor01 in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 4th May 2024, 21:31
  2. how to display data receiving from xbee to LCD
    By NURULHAIZA in forum mel PIC BASIC
    Replies: 2
    Last Post: - 19th November 2010, 22:24
  3. Sending/receiving data using Linx modules
    By Goat 403 in forum Serial
    Replies: 3
    Last Post: - 21st May 2009, 14:57
  4. Receiving and Transmitting Serial data at the same time
    By BobP in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th April 2007, 23:00
  5. Receiving data from more than one serial Port
    By PICtron in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th March 2005, 11:20

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts