12f675_fuse_about_to_blow!


Closed Thread
Results 1 to 40 of 929

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit,

    Not sure I have a strong point...
    Hey, you put up with me, so patience is one of them

    And don't forget it was trying to turn an LED on using ASM that after a near breakdown put me onto PBP

    I'll go onto MATCH & DECODE tomorrow, slowly getting there (slowly).

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    It still doesn't take much to stump me I'm afraid........

    Code:
     MATCH = MATCH + 1        ' We have a match so increment match count
        IF MATCH = 2 THEN DECODE ' Everything matched twice, we're good
        GOTO Main                ' Else do it all over
    When the Timer was set up for a 65ms reset we had:

    Code:
    MATCH = 0           ' Clear match count
    Then the SYNCH_BYTE & DATA etc arrived and everything was good giving:

    Code:
    MATCH = MATCH + 1        ' We have a match so increment match count
    So to my mind that makes MATCH = 0 +1 ie 1.

    But then we have:

    Code:
     IF MATCH = 2 THEN DECODE ' Everything matched twice, we're good
    So either the data arrives twice within the 65ms time period to move onto DECODE or my understanding of MATCH = MATCH + 1 is wrong.

    Help!

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    So either the data arrives twice within the 65ms time period to move onto DECODE or my understanding of MATCH = MATCH + 1 is wrong.
    Not within the 65ms but just twice. MATCH does not get set to zero until DECODE is reached.
    One good set of data could arrive then many not-goods, then one more good THEN DECODE.

    Being this came from Bruce it is hard for me to question it but....
    Here is what I think it should be
    Code:
        ' Test new checksum against one received in CHK_SUM
        IF CheckSum != CHK_SUM THEN MAIN ' Failed checksum, return
        MATCH = MATCH + 1        ' We have a match so increment match count
    
        ' Test data bytes for match
        IF (DAT_IN1) != (DAT_IN2) THEN MAIN ' Failed data comparison, return
        MATCH = MATCH + 1        ' We have a match so increment match count
    
        IF MATCH = 2 THEN DECODE ' Everything matched twice, we're good
        GOTO Main                ' Else do it all over
    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

    Far more intuitive for a newbie your way mackrackit. I would have been stuck in a loop looking for a second MATCH until my watchdog timer kicked in (that's not to say Bruce's program isn't pure genius from where I'm sitting).

    I'm thinking that if one MATCH had occurred but was followed by bad data, then the ASM :

    Code:
    clrf   MATCH         ; Clear match variable
    would reset the single MATCH to zero after 65ms?

    Onto DECODE then.

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    Code:
      ' hardware init
        PORTA = 0
        TRISA = %00111001   ' RA1 and RA2 are LED outputs
    So PORTA.1-2 are outputs

    And BYTES received will be
    Code:
    %10101011 or %10101101
    Code:
    PORTA = DAT_IN1 & %00000110
    The manual says:Bitwise Operators: & %00000001 ' Isolate bit 0 of BYTE.

    So I'm thinking: & %00000110 ' Isolate bits 1 & 2, would give:

    %00000010 from %10101011 & %00000100 from %10101101 as PORTA, depending on which button was pressed and light the LED's.

    Hot, cold or tepid?

    Dave
    Last edited by LEDave; - 24th November 2010 at 20:05.

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


    Did you find this post helpful? Yes | No

    Default

    Hot, cold or tepid?
    Hot
    Looks like you got it.

    BTW, I missed
    Code:
    clrf   MATCH         ; Clear match variable
    So the original code would have to receive two good with out a bad. I wonder why Bruce did it that way?
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Cheers mackrackit

    So the original code would have to receive two good with out a bad. I wonder why Bruce did it that way?
    I don't know.....

    One thing though, from Bruce's code (and please bear in mind this is the thinking of a newbie here).The only way(as I see it) that MATCH can ever reach a count of two and then move onto 'DECODE' is for the program to run from 'SERIN2' all the way to 'GOTO Main' once and then a second time to 'IF MATCH = 2 THEN DECODE' for MATCH to ever equal 2. Am I missing something here?

    Code:
    ' Wait for Synch byte, then get new inbound data & checksum
        SERIN2 D_IN,N2400,[WAIT(Synch),DAT_IN1,DAT_IN2,CHK_SUM,TEST]
        
        T1CON.0 = 0    ' Stop Timer1 once we've received data
        TMR1L = 0      ' Clear low byte
        TMR1H = 0      ' Clear high byte
        
        ' / **** Begin data validation **** /
        
        ' Calculate checksum by adding 2 data bytes together
        CheckSum = DAT_IN1 + DAT_IN2
        
        ' Test new checksum against one received in CHK_SUM
        IF CheckSum != CHK_SUM THEN MAIN ' Failed checksum, return
        
        ' Test data bytes for match
        IF (DAT_IN1) != (DAT_IN2) THEN MAIN ' Failed data comparison, return
        
        MATCH = MATCH + 1        ' We have a match so increment match count
        IF MATCH = 2 THEN DECODE ' Everything matched twice, we're good
        GOTO Main                ' Else do it all over
    Dave
    Last edited by LEDave; - 25th November 2010 at 16:05.

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