12f675_fuse_about_to_blow!


Closed Thread
Results 1 to 40 of 929

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Sounds pretty good to me.

    A point though..
    RESET_VT
    inside the ASM part of the code is an ASM label.
    DEFINE INTHAND RESET_VT
    Tells where to go when the interrupt occurs.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit.

    My mistake, I should have said:

    If the count reaches 65536ms then the Interrupt flag TMR1IF PIR.0 goes to 1 then the program jumps to:
    Code:
    RESET_VT
    Not the DEFINE.

    So when the program jumps after PIR.0 = 1 to RESET_VT it then runs the Register saving code, then the INTERRUPT routine, then restores all the previously saved values back to exactly the same condition as pre - RESET_VT. Can we come back to that part the ASM stuff later but for now assume there was some DATA received and the next block of PBP code.

    Dave

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Can we come back to that part the ASM stuff later but for now assume there was some DATA received and the next block of PBP code.
    Yup, sounds like you have the interrupt idea worked out.
    On to MAIN...
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    MAIN:
    ' Fire up Timer1 before entry to serial input routine
    T1CON.0 = 1
    So the Timer1 is running and we've got 65.5ms to receive the data.

    I guess a question here would be how fast does a PIC receive DATA? At the moment we're only receiving the SYNCH - DAT_IN1 - DAT_IN2 & CHK_SUM BYTES. If for example when the project is running and we send accumalative Bird Box Visit_Data (day1 + day2 etc.....n) then after a Month we'd have 30 Bytes or Words even, would that time_out? Because as the program stands:

    Code:
    T1CON.0 = 0
    After the Data has arrived.

    Anyway moving on.

    So the Data has arrived:

    Code:
    SERIN2 D_IN,N2400,[WAIT(Synch),DAT_IN1,DAT_IN2,CHK_SUM]
    Then:

    Code:
     T1CON.0 = 0    TMR1L = 0  TMR1H = 0
    So Timer1 is stopped - TMR1H&L BYTES cleared.

    Before I carry on with **Begin Data Validaition**

    What does the ! in: IF CheckSum ! mean please mackrackit.

    Dave
    Last edited by LEDave; - 21st November 2010 at 16:57.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Manual section
    4.18. Comparison Operators
    Not equal !=

    I guess a question here would be how fast does a PIC receive DATA?
    I think once the PIC starts receiving with SERIN2 it will not stop till finished. I will have to check to be.
    Dave
    Always wear safety glasses while programming.

  6. #6
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Manual section
    4.18. Comparison Operators
    Not equal !=
    Cheers mackrackit, thanks for the pointer.

    Dave

  7. #7
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    Calculate checksum by adding 2 data bytes together
    Code:
    CheckSum = DAT_IN1 + DAT_IN2
    So the CheckSum = (%10101011 * 2 BYTES) if SW1 ( GPIO.3) was pressed.

    or (%10101101 * 2 BYTES) if SW2 (GPIO.4) was pressed.

    Plus we should have the already have a calculated CHK_SUM that was sent.

    So:

    Code:
    CHK_SUM   VAR BYTE  ' Holds checksum received
    And:

    Code:
    CheckSum  VAR BYTE  ' Computed checksum of all bytes received
    Therefore:

    Code:
    IF CheckSum != CHK_SUM THEN MAIN ' Failed checksum, return
    If Checksum (!) is not = CHK_SUM then go back to MAIN the checksum has failed.

    The same with:

    IF (DAT_IN1) != (DAT_IN2) THEN MAIN ' Failed data comparison, return
    The DAT_IN BYTES must also be equal, if not then back to MAIN:

    If however everything matches then continue to MATCH..........

    How does this look?

    Dave
    Last edited by LEDave; - 22nd November 2010 at 18:59.

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