$


Closed Thread
Results 1 to 3 of 3

Thread: $

  1. #1
    Join Date
    Aug 2005
    Location
    down south
    Posts
    90

    Default $

    I'm learning to program in pbp-cdlite and looking at some code that I found, I saw this not sure but is "$0" and "$90" reseting all the flags and interupts.
    in the OPTION_REG. AND INTCON

    please explain

    MAIN
    OPTION_REG=$0
    ON INTERRUPT GoTo bump
    INTCON=$90

    just trying to learn, asking for a little help

    thanks

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    $ is just a tag that mean it's a HEX value.

    The PBP default 'radix' (if i can call it like that) is dec. So when you want to use Binary or Hex value, you must tell to the compiler.

    MyVar=10 <= 10 decimal
    Myvar =$90 <= 90 HEXadecimal
    MyVar=%11110000 <= Binary value = $F0 = 240 decimal

    Code:
    please explain
    
    MAIN
    OPTION_REG=$0
    ON INTERRUPT GoTo bump
    INTCON=$90
    Hard to say what it does if we don't know the PIC model. BUT many times, some of the interrupts flags are reset in the INTCON register.
    Better and safer if you refer to your PIC datasheet to see what it do.

    In my case, i prefer to use Binary as value. Easier to refer to the datasheet after few months/week/year/Century/milenium ...

    INTCON=%10010000 is easier to figure out with the datashet than INTCON=$90 IMHO once again.
    Also use Alias/Symbol to access directly to a specific register bit, Let's say
    Code:
    RCIF    VAR PIR1.5   ' USART rx interrupt flag => Buffer full/empty
    GO_DONE VAR ADCON0.0 ' ADC conversion status bit
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Aug 2005
    Location
    down south
    Posts
    90


    Did you find this post helpful? Yes | No

    Default

    thank you mister_e

    I had alway used the $0 and $90 because a guy sent me some code and he used it. but I did not know what it meant. but it worked.
    I 1st.did the code below with it and it worked. and then I did the code looking things up in the data sheet (like you suggested) and again it worked.

    INTCON.4=1 'ENABLE RA2 EX. INT.
    OPTION_REG.6=0 'SET RA2/INT FOR FALLING EDGE
    INTCON.1=0 'RESET RA2/INT

    ON INTERRUPT GoTo BUMP


    I was thinking it might be some kinda wild card that reset everything.
    don't laugh at my code I just learning.

    DEVICE pic16f630
    @ DEVICE pic16f630, INTRC_OSC_NOCLKOUT
    @ DEVICE pic16f630, WDT_ON
    @ DEVICE pic16f630, MCLR_OFF
    @ DEVICE pic16f630, CPD_OFF '16F630 TEST
    @ DEVICE pic16f630, BOD_OFF
    @ DEVICE pic16f630, PWRT_ON
    @ DEVICE pic16f630, PROTECT_OFF
    DEFINE OSC 4
    Pause 20000 'ALLOW TO STABILIZE AFTER POWER UP Allow
    TRISA = %00101100 'MAKE A.5,A.2 & A.3 INPUTS
    TRISC = %00000000 'MAKE ALL PORTC OUTPUTS

    OPTION_REG.7 = 0 'ENABLE PULL-UPS
    WPUA = %00110111 'WEAK PULL-UPS ON PORTA



    SYMBOL GREEN = PORTC. 'GREEN LED
    SYMBOL TRIG = PORTA.2 'INTERUPT INPUT
    SYMBOL NOW = PORTA.5 'NONE INTERUPT INPUT
    SYMBOL ORG = PORTC.2 'ORG LED
    SYMBOL RED= PORTC.3 'RED LED

    TRIG= 0
    GREEN = 0
    NOW = 0
    ORG =0
    RED =0
    GREEN=1 'power up ok
    Pause 4000
    GREEN= 0
    Pause 2000

    IF NOW =0 Then GoTo LONG 'SELECT LONG OR BUMP
    GoTo MAIN

    MAIN
    'OPTION_REG=$0
    INTCON.4=1 'ENABLE RA2 EX. INT.
    OPTION_REG.6=0 'SET RA2/INT FOR FALLING EDGE
    INTCON.1=0 'RESET RA2/INT

    ON INTERRUPT GoTo BUMP
    'INTCON=$90


    REFRESH:
    Sleep 20 'EVERY 20 SEC. TURN A DIFFRENT LED ON FOR 6SEC. THEN OFF
    ORG=1
    Pause 6000
    ORG=0
    Sleep 20
    GREEN=1
    Pause 6000
    GREEN=0
    Sleep 20
    RED=1
    Pause 6000
    RED=0



    GoTo REFRESH

    Disable


    GoTo MAIN

    BUMP:

    GREEN = 1 'GREEN LED ON
    Pause 1500 'FOR 1.5 SEC.
    ORG=1 'ORG LED ON
    Pause 1500 'FOR 1.5 SEC.
    RED = 1 'RED LED ON
    Pause 3000 'HOLD FOR 3 SEC.
    GREEN=0 'GREEN LED OFF
    ORG=0 'ORG LED OFF
    RED=0 'RED LED OFF


    INTCON.1=0
    Disable

    GoTo MAIN



    LONG
    GREEN=1
    Pause 3000
    GREEN=0
    Pause 1000
    RED=1
    Pause 3000
    RED=0
    Pause 1000
    ORG=1
    Pause 3000
    ORG=0

    INTCON.1=0

    GoTo LONG
    Enable

Similar Threads

  1. PBP projects for R/C models
    By malc-c in forum Code Examples
    Replies: 771
    Last Post: - 21st October 2016, 12:56
  2. lambda probe interface IC - CJ125 from Bosch
    By almarto in forum Off Topic
    Replies: 16
    Last Post: - 29th March 2011, 18:36
  3. 12F629 LDR - Light Dependant Resistor
    By Dennis in forum Schematics
    Replies: 15
    Last Post: - 18th February 2010, 22:33
  4. SHIFTOUT Clock rate
    By Brock in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 8th July 2006, 23:42
  5. does this piece of code look ok?
    By Richardco in forum mel PIC BASIC Pro
    Replies: 26
    Last Post: - 30th November 2005, 20:34

Members who have read this thread : 1

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