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

    I've been doing lots of reading and slowly trying to work my way through the TX / RX progs to get an understanding of what's actually happening, the sequence etc. One thing I can't see though is this.

    In the TX program we've got:

    Code:
    SEROUT2 D_OUT,BAUD,[PreAmble,Synch,DAT_OUT,DAT_OUT,CHK_SUM]
    And the RX has:

    Code:
    SERIN2 D_IN,N2400,[WAIT(Synch),DAT_IN1,DAT_IN2,CHK_SUM]
    So my Q is this: What's happened to the 'PreAmble BYTE' ?

    Code:
    PreAmble CON $A5    ' 10100101 preamble
    The Manual says:

    The list of data items to be received may be preceded by one or more qualifiers between parenthesis after WAIT. SERIN2 must receive these bytes in exact order before receiving the data items. If any byte received does not match the next byte in the qualifier sequence, the qualification process starts over
    So in this case that would be the Synch BYTE right? Synch BYTE always first (because of the WAIT command), the rest to follow. I can't see where / how the preAmble arrives though.

    Also this from WIKI:

    http://en.wikipedia.org/wiki/Syncword

    Suggest to me that a PreAmble and a Synch are two ways of doing the say thing, or very similar, have a got that on right?

    Dave
    Last edited by LEDave; - 8th November 2010 at 21:54.

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


    Did you find this post helpful? Yes | No

    Default

    The short answer about the pre-amble is it sets up the receiver hardware with data that is not noise so when the remainder of the data comes in, in our case the SYNCH, the SYNCH byte is easily detected from noise.... The receiver hardware acts on it but not the receiver code.
    SYNCH is for software
    PRE-AMBLE is for hardware
    Something like that.

    The long answer.
    http://davehouston.net/RFTipsTricks.htm
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit, thanks for the reply.

    I'll settle for the short answer right now (I'm off to bed in a mo) and read the long answer tomorrow.

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    Bruce's program is very well documented, it would be good to know I'm reading how to put the PIC to sleep and wake on interrupt. Am I on the right lines here?

    Code:
    INTCON = %00001000  ' Enable port change wakeup from sleep
    Setting INTCON REG bit 3 to 1 enables the GPIO port change interrupt, the interupt flag is set on INTCON REG bit 0. (I'm thinking bit.0 is now logic 1 until cleared.)

    Code:
    IOC = %00011000     ' Wakeup on change enabled for GPIO.3,4
    Setting the IOC pins 3 / 4 (button presses) to logic 1 (goes low when button pressed).

    Code:
    Main:    
        ' Read port to clear missmatch, if with no buttons pressed, then
        ' clear int-on-change flag & snooze until wake up on change. This
        ' conserves battery power on the demo board with 3V coin cell.
        IF (GPIO.3=1) AND (GPIO.4=1) THEN ' pins will be 0 only when buttons are pressed
         E_OUT=0         ' Disable transmitter
         INTCON.0 = 0    ' No buttons down, so clear int on change flag
         @ SLEEP         ' and start snoozin..zzzzzzzzzzz
         @ NOP           ' Do nothing for 1st instruction on wake-up
        ENDIF
        E_OUT=1          ' Enable transmitter (+ lights RFEN LED on demo board)
        PAUSEUS 25       ' Allow RF stage to stabilize
    So if no button is pressed:
    1/ GPIO.3 / 4 stay high
    2/ E_OUT=0 the transmitter (SYMBOL E_OUT = GPIO.5 ' RF transmitter enable output) stays off.
    3/ INTCON.0 = 1 changes to INTCON.0 = 0 (software reset)
    4/ @ SLEEP (The PIC goes to sleep, no time value set).
    5/ @ NOP (I'll take as per NOP above, I couldn't find anything on this in the manual).

    If buttons on GPIO.3/4 are pressed then the program continues....... As I will tomorrow.

    How does this look?

    Dave

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


    Did you find this post helpful? Yes | No

    Thumbs up

    3/ INTCON.0 = 1 changes to INTCON.0 = 0 (software reset)
    INTCON.0 will only "=1" when one of the IOC pins change state. The code makes sure the "trigger" is set before sleeping. I think you got that though.

    5/ @ NOP (I'll take as per NOP above, I couldn't find anything on this in the manual).
    No Operation... I am here but I ain't doing nothing.
    Look to the data sheet under Instruction Set Summary. The ASM instructions are found there.

    Looks like you have been studying
    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

    Cheers mackrackit, I was pretty close then-ish.

    I think I've got the whole sequence now:

    INTCON REG bit 3 set to 1 enables the INTCON REG flag bit 0. Bit 0 changes 'flags' when a button is pressed which is controlled by ( IOC = %00011000 - the buttons in effect)

    It was this line from the program that threw me:

    Code:
    INTCON.0 = 0    ' No buttons down, so clear int on change flag
    I originally thought that if no buttons were down then INTCON.0 = 0 so there was no flag to clear but on reading Bruce's:
    ' No buttons down, so clear int on change flag
    made me think it must be set to '1'.

    Thanks for the explanation.

    Dave
    Last edited by LEDave; - 14th November 2010 at 16:21.

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


    Did you find this post helpful? Yes | No

    Default

    Sometimes it is hard to say. From the data sheet.
    bit 0 GPIF: Port Change Interrupt Flag bit
    1 = When at least one of the GP5:GP0 pins changed state (must be cleared in software)
    0 = None of the GP5:GP0 pins have changed state
    If one of the two buttons were down and the other up when the bit was cleared,( made zero), then releasing one OR pushing the other will cause the flag to be set, (bit 0 = 1) , just looking for a change, any change.
    Dave
    Always wear safety glasses while programming.

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