Extreme Noobie question 12F675


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Location
    Spokane, WA
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    Hey, thanks for answering, skimask. I am running PICBASIC 2.3.0.0. My button is pulled up with thru a resistor, so when button is pressed, pin goes low - to ground.

    I could not compile your code. Maybe I am missing something:
    POKE $9f,0
    POKE $1f,254
    POKE $85,255
    symbol PORTA=5
    POKE PORTA, 0
    Loop1: PEEK PORTA, B0 'COPY PORTA REG, PUT IN VARIABLE B0
    IF B0 = 1 THEN HIGH 0
    IF B0 = 0 then LOW 0
    goto loop1
    end

    It gets stuck on the "IF B0" lines. Couple more questions: Can I address the pins on this chip using "GPIO". You mentioned that I was using PortA. Maybe it is the same thing; Port A being used on IC's with more than one port? (sounds like maybe I answered my own Q but gotta ask.) Also, how do you make the code quote box? Thanks in advance!

    Jeff

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Jeff View Post
    Hey, thanks for answering, skimask. I am running PICBASIC 2.3.0.0. My button is pulled up with thru a resistor, so when button is pressed, pin goes low - to ground.

    I could not compile your code. Maybe I am missing something:
    POKE $9f,0
    POKE $1f,254
    POKE $85,255
    symbol PORTA=5
    POKE PORTA, 0
    Loop1: PEEK PORTA, B0 'COPY PORTA REG, PUT IN VARIABLE B0
    IF B0 = 1 THEN HIGH 0
    IF B0 = 0 then LOW 0
    goto loop1
    end

    It gets stuck on the "IF B0" lines. Couple more questions: Can I address the pins on this chip using "GPIO". You mentioned that I was using PortA. Maybe it is the same thing; Port A being used on IC's with more than one port? (sounds like maybe I answered my own Q but gotta ask.) Also, how do you make the code quote box? Thanks in advance!

    Jeff
    Hi Jeff,
    I have not used PBC but I tell ya what I think: Change PEEK PORTA to PEEK GPIO.5 and POKE PORTA to POKE GPIO.5 and lose the symbol PORTA=5, I think your compiler is really looking for PortA which is unsupported for this chip. WOW glad I bought the pro version this looks a lot tougher to use.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Jeff View Post
    Hey, thanks for answering, skimask. I am running PICBASIC 2.3.0.0
    PicBasic 2.30 huh? I don't see that option on the MeLabs upgrades page...
    http://www.melabs.com/support/upgrade.htm
    Unless the MeLabs page is wrong, the 12F675 isn't support until version 1.44 of PicBasic...and isn't supported until version 2.42 for PicBasicPro.

    So again...
    Which version do you have?
    Where'd you get it?
    Why not spend the $25 for the upgrade to the latest greatest?

  4. #4
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Hi Jeff,

    I have not used Pic Basic Compiler for almost 10 years but here are some comments and items to check/change to get you going.

    Code:
    SYMBOL ANSEL = $9F '$19 IS ANSEL REGISTER 
    POKE ANSEL, 0 'MAKE PIN DIGITAL, NOT ANALOG
    this looks good except your comment is for CMCON not ANSEL (see below)

    Code:
    SYMBOL ADCON0 = $1F 'TURN OFF A/D ON PIN4. (DEFAULT IS ON)
    POKE ADCON0, 254 '$1F IS ADDR OF A/D REGISTER. 10011111 (7)
    you do not need to fiddle with ADCON0 unless you want to use the A2D module. You should leave these two lines out. As it stands now, these two lines set up the A2D to acquire AN3 using a reference voltage on pin GP1, which might be messing you up. The pins do default to analog but changing them to digital is accomplished with ANSEL and CMCON.


    You need to disable the comparators so add something like this

    Code:
    SYMBOL CMCON = $19 '$19 IS CMCON  REGISTER 
    POKE CMCON, 7 'MAKE PIN DIGITAL, NOT ANALOG
    Code:
    SYMBOL TRISA = $85 'SETUP PINS DATA DIR I/O
    POKE TRISA, 255 'MAKE DATA I/O GP0 AN OUTPUT, GP1 AN INPUT 
    'AND MAKE GP1 AN INPUT (ALL OTHERS ARE OUTS)
    Here the poke 255 is actually making everything inputs. If you want everything to be inputs except GP0, then poke 254

    Code:
    symbol PORTA = $05 '$05 IS OUTPUT DATA REGISTER
    POKE PORTA, 0 'TURN OFF ALL BITS
    turns off all outputs so okay

    Code:
    Loop1: PEEK PORTA, BIT0 'COPY PORTA REG, PUT IN VARIABLE B0
    you need to peek porta into a byte sized variable. Try PEEK PORTA, B0 as noted in your comment

    Code:
    IF BIT0 = 1 THEN LOOP1 'WHEN BUTTON IS PUSHED, INPUT GOES LOW
    this does check bit 0 of B0 but you wanted GP0 to be an output? Maybe you want to check the bit where your switch is connected.?


    Code:
    loop2: High 0 'Turn on LED connected to GP0
    Pause 500 'Delay for .5 seconds
    
    Low 0 'Turn off LED connected to GP0
    Pause 500 'Delay for .5 seconds
    
    Goto loop2 'Go back to loop and blink LED forever
    this trap looks good.


    One last comments - Ski is correct, it is strange to rename the GPIO port to PORTA. Consider changing all PORTA refs above to GPIO. The same goes for TRISA - change to TRISIO

    reply back with progress for more help
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  5. #5
    Join Date
    Jan 2005
    Location
    France
    Posts
    97


    Did you find this post helpful? Yes | No

    Default 12F675 study

    Hello
    First, I have made a search on that PIC but I didn't find any answer on the following questions :

    1/ Am I right if I say that the VSS and VDD pins are not in the same way than the well known 16F84 ?
    we must make an adaptator to use a JDM programmer and having RB6 (pin 12) and RB7 (pin 13) pins on pin 7 and 6 on the 12F675 (assuming that we reverse VSS and VDD) and take pin 4 of the 16F84 to pin 4 on the 12F675 ! hope it is clear !

    2/ we must read first the 12F675 to store oscal and bandgap datas ?

    3/ we must play with CMCOM and Ansel command to have Digital port instead of analog status a power on time. (same story than for 16F628 or 16F88)

    4/ we must forget PORTA and use GPIO to declare activ pins ?

    5/ we must modify HEX file to feed oscal and bangap datas before programming ?

    if I can find the famous BLINK.BAS program for 12F675, I will save time ...

    what else ? nespresso pub ?

    thanks

    Francois

Similar Threads

  1. Still 12F675 question
    By F1CHF in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th August 2009, 21:09
  2. Noobie Question
    By mel4853 in forum mel PIC BASIC
    Replies: 19
    Last Post: - 2nd July 2006, 12:45
  3. 12F675, MPLAB programming question
    By EASY in forum General
    Replies: 0
    Last Post: - 2nd April 2006, 19:28
  4. 12f675 programming question
    By puggy in forum General
    Replies: 3
    Last Post: - 30th November 2004, 23:34
  5. 12f675 internal osc question.....
    By Gabe@SPdFtsh in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 6th January 2004, 06:33

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