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 Joe

    Very impressed with the two programs you posted, thanks for those and very clever. The coding in parts is way beyond me at present but the effect on my PIC1 board are great and shows what can be done.

    I'll try and do the sequence mackrackit suggested today (time permitting).

    "So now try to do the sequence LEDs 1-3 using HIGH/LOW."

    It sounds straight forward enough (ish) but I've just got a feeling.......!

    Dave

  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. I've been working like a Beaver this PM and have come up with this program to your: "So now try to do the sequence LEDs 1-3 using HIGH/LOW." exercise. If you get a minute could check my program comments for accuracy please, because I'm making assumptions the conclusions I'm drawing are accurate and they may well not be. The program does work though:Many thanks: Dave


    ANSEL = %00000000
    CMCON0 = %00000111

    Sart
    MAIN
    OUTPUT GPIO.5 ' Makes GPIO.5 an output
    LOW GPIO.4 ' Makes GPIO.4 zero volts
    HIGH GPIO.5 ' D1 HIGH turns LED-ON +5 volts
    PAUSE 500 ' wait 500mili_secs
    LOW GPIO.5 ' D1 LOW turns LED-OFF
    PAUSE 500 ' wait 500mili_secs

    INPUT GPIO.5 ' Stops cross-feed to other Diodes
    OUTPUT GPIO.4 ' Makes GPIO.4 an output
    LOW GPIO.2 ' Makes GPIO.2 zero volts
    HIGH GPIO.4 ' D2 HIGH turns LED-ON +5 volts
    PAUSE 500 ' wait 500mili_secs
    LOW GPIO.4 ' D2 LOW turns LED-OFF
    INPUT GPIO.2 ' Stops cross-feed to other Diodes
    PAUSE 500 ' wait 500mili_secs

    OUTPUT GPIO.2 ' Makes GPIO.2 an output
    LOW GPIO.4 ' Makes GPIO.4 zero volts
    HIGH GPIO.2 ' D3 HIGH turns LED-ON +5 volts
    PAUSE 500 ' wait 500mili_secs
    LOW GPIO.2 ' D3 LOW turns LED-OFF
    INPUT GPIO.2 ' Stops cross-feed to other Diodes
    PAUSE 500 ' wait 500mili_secs

    goto MAIN ' start all over again
    Last edited by LEDave; - 23rd February 2010 at 19:07.

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


    Did you find this post helpful? Yes | No

    Default

    So here's a question (or yet another question to be more accurate here).

    Is it possible to use multiple OUTPUT & HIGH statements on one line for example:

    OUTPUT GPIO.0 GPIO.1 GPIO.2

    As opposed to:

    OUTPUT GPIO.0
    OUTPUT GPIO.1
    OUTPUT GPIO.2

    Followed by:

    HIGH GPIO.0 GPIO.1 GPIO.2

    As opposed to:

    HIGH GPIO.0
    HIGH GPIO.1
    HIGH GPIO.2

    David

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default

    Yes and no, you can use our old friend Skimask's favourite character - the colon - and do
    Code:
    High GPIO.0 : High GPIO.1 : High GPIO.2
    But it doesn't make any difference as to how it actually works, it will generate exactly the same code when compiled as having each command on a separate line.

    What you usually do is write directly to the register, or port in this case, like this:
    Code:
    TRISIO = %11100000 'Set lower five bits to outputs
    GPIO = %00000111   'Set the lower three bits.
    PAUSE 1000
    GPIO = %00010101   'Set some other bits.
    The HIGH and LOW commands automatically sets the pin to an output (by also writing to the TRIS register "behind the scenes" (basically what the OUTPUT command does)) which is handy sometimes but completely unneccessary to do EVERY time you change the state of the pin. By using the more "direct" aproach you'll save code space and execution time.

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


    Did you find this post helpful? Yes | No

    Default

    Thanks for that Henrik.

    For my first project I'd like to use a 12F683 generate a four bit word to load a
    BCD / Seven Segment Display driver. Would the code below work do you think?


    TRISIO = %11110000 'Set lower fOUR bits to outputs: 4 bits all you need to create bcd OUTPUT.

    GPIO = %00000000 'Set all bits low: Would drive a BCD / 7 SEG to OUTPUT '0'

    PAUSE 1000

    GPIO = %00000001 'Set BIT.0 High: Would drive a BCD / 7 SEG to OUTPUT '1'

    pause 1000

    GPIO = %00000010 'Set BIT.1 High: Would drive a BCD / 7 SEG to OUTPUT '2'

    pause 1000

    GPIO = %00000011 'Set BIT.2 & BIT.1 High: Would drive a BCD / 7 SEG to OUTPUT '3'

    PAUSE 1000

    GPIO = %00000100 'SET BIT.2 HIGH: Would drive a BCD / 7 SEG to OUTPUT '4'

    etc,etc........

    David

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


    Did you find this post helpful? Yes | No

    Default

    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by LEDave View Post
    Hi Joe

    Very impressed with the two programs you posted, thanks for those and very clever. The coding in parts is way beyond me at present but the effect on my PIC1 board are great and shows what can be done.

    I'll try and do the sequence mackrackit suggested today (time permitting).

    "So now try to do the sequence LEDs 1-3 using HIGH/LOW."

    It sounds straight forward enough (ish) but I've just got a feeling.......!

    Dave
    Hi Dave,
    Really simple and not beyond where you are right now.
    Tris is short for TriState. 3 states: in / output H / output L
    Port determines if the tristate is high or low.
    "Most" of the 12F , 8 pin devices use GPIO as Port name, it stands for General Purpose Input output. the TRIS is TRISIO. Here is the really simple part the letter" I " (for input) looks like a number 1 and the letter" O" (for Output) looks like a 0. so you see GPIO%00000011 means the 2 lowest bits are "set" as inputs. All the other bits are " cleared ". and are Outputs.
    The Port register is done in a similar way. 1 is logic HIGH and 0 is logic LOW. Logic high is +5v and Logic Low is 0 volts.
    I get that you might know this, but the next newbie may not. No offense intended.
    Consider this statement:
    TRISIO = %11111001
    GPIO = %00000010 'LED 7 ON

    TRISIO = %11111001 makes ports 1:2 into outputs
    GPIO = %00000010 makes Port 1 Logic high and port 2 logic low.
    Pay attention to the terminology "set" & "cleared" as you will see them in the data sheets.
    Generally speaking you will set the Port first then the tris, if you have a circuit like this where you have a bidirectional load, you might consider making all tris as inputs, set your port and then set the tris to enable the outputs. Your loads might be something very different than LEDs.
    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.

  8. #8
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default

    Dave,
    Sure, that should work. You can also use the value stored in a variable when writing to the register, like this:
    Code:
    i VAR BYTE     'Declare a variable named 'i' as a BYTE
    i = 8
    GPIO = i   'Will set GPIO to %00001000
    This in turn means that to make the display count you can do this:
    Code:
    i VAR BYTE     'Declare a variable named 'i' as a BYTE
    MAIN:
    FOR i = 0 to 9 'Count up, from 0 to 9
      GPIO = i
      Pause 500
    Next
    
    FOR i = 9 to 0 STEP -1  'Count Down, from 9 to 0
      GPIO = 0
      Pause 500
    Next
    
    Goto Main             'Do it again
    May I kindly suggest that you also read thru the PBP manual a lot of what we've gone thru here is available in it, sometimes in a bit more condensed form but if you read thru it you'll get a better picture of "what's available", then we can work on the details and specifics together.

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


    Did you find this post helpful? Yes | No

    Default

    Once again many thanks for all the INPUT.As always very much appreciated.

    mackrackit, I've book marked that link, very useful.

    Joe, if I could get my PIC's to dance like that I'll know I've arrived. I'm still adding the building blocks at present, that said there's been a big improvement in what I know and can do in just a week, great stuff.

    Henrik, so are we're saying that the program is counting up from 0-9 in bytes? Does it load and output the values $00000000 (LOOP1) $00000001 (LOOP2) ...etc. If that's the case I could directly output to a seven segment display!

    So the question is: Is there a PIC for my PICkit1 that has an eight bit wide output GPIO?

    Dave

  10. #10
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    From here http://www.microchip.com/stellent/id...cName=en010053
    PICkit Classic V1.74 supports these mid-range Flash PIC® microcontrollers:
    - PIC12F629, 635, 675, 683,
    - PIC16F630, 636, 676,

    - PIC16F684, 685, 687, 688, 689, 690, 785

    - PIC16F913, 914, 916, 917, 946
    Any of those in red have at least one 8-bit port. Although, the same page also say this.
    The PICkit™ 1 Flash Starter Kit is a low-cost development kit with an easy-to-use interface for programming Microchip’s 8-/14-pin Flash family of microcontrollers.
    If that is the case, then you are out of luck as no 8/14-pin devices have a complete 8-bit port.
    Last edited by rmteo; - 24th February 2010 at 16:04.

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


    Did you find this post helpful? Yes | No

    Default

    So the question is: Is there a PIC for my PICkit1 that has an eight bit wide output GPIO?
    None that I can think of. The 14 pin PICs will have two ports with 6 each.

    You migh get creative and shift the bits 4 four places.
    Lower four to one port, upper four to the other???

    Or...

    I think Darrel had a way of re-mapping the pins/ports...
    Dave
    Always wear safety glasses while programming.

  12. #12
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default

    Henrik, so are we're saying that the program is counting up from 0-9 in bytes? Does it load and output the values $00000000 (LOOP1) $00000001 (LOOP2) ...etc. If that's the case I could directly output to a seven segment display!
    Yes and no, the loop incements the variable i from 0 to 9 (or what ever you want it to) and writes its value to the GPIO-register, the pattern on the GPIO will be the binary representation of the number, ie:

    00000000 '0
    00000001 '1
    00000010 '2
    00000011 '3
    ...
    00001000 '8
    00001001 '9

    This however, can not drive a 7-segment display directly as displaying "1" needs two segments turned on (but only one bit is set on the "count" of 1) and 8 needs all seven segments on but at the "count" of 8 there's again only a single bit set.

    However, you can use the LOOKUP command to "translate" the 0-9 count into the "patterns" needed to drive the segments. Lets say you connect the display so that each bit drive the segments as per the attached picture. To display "3" bit 0, 1, 2, 3 and 6 would need to be set, or put another way, you'd need to write %01001111 or 79 to the port. To display a "2" you need to set bits 0, 1, 3, 4 and 6 (%01011011 or 91) and so on.

    Now lookup the LOOKUP command in the manual ;-)
    Attached Images Attached Images  

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


    Did you find this post helpful? Yes | No

    Default

    HI Henrik

    I've looked lookup in the manual (I found a copy on the net, then realised there's one in the demo-program...doh).

    So are we saying that to make the seven segment display show a '3' our loop count would be:00000011 '3' but that would LOOKUP a stored value of :%01001111 and display that?

    So we'd have to 'load in' somewhere a table of values:

    %01001111 3 b3
    %01011011 2 b2
    %00000110 1 b1
    %00111111 0 b0

    So:

    FOR B0 = 0 TO 3 ' Count from 0 to 3
    LOOKUP B0,[%00111111],B1 ' Get character number B0 from string to variable B1
    SEROUT 0,N2400,[B1] ' Send character in B1 to Pin0 serially
    NEXT B0 ' Do next character

    *Shouldn't SEROUT be something like PAROUT (parallel out) namely display all seven bits on seven pins at once.*

    Dave (struggling but trying).
    Last edited by LEDave; - 24th February 2010 at 18:14.

  14. #14
    Join Date
    Jan 2009
    Location
    California, USA
    Posts
    323


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    I think Darrel had a way of re-mapping the pins/ports...
    http://www.picbasic.co.uk/forum/show..._anypin&page=2



    steve

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