12f675_fuse_about_to_blow!


Closed Thread
Results 1 to 40 of 929

Hybrid View

  1. #1
    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.

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    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  

  3. #3
    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 17:14.

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


    Did you find this post helpful? Yes | No

    Default

    *Shouldn't SEROUT be something like PAROUT (parallel out) namely display all seven bits on seven pins at once.*
    No,
    GPIO = B1
    will set the bits to whatever B1 is.

    SERIOT is for RS232 type stuff.

    Another lesson
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit

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

    How difficult is getting creative for a newbie like me?

    My PICkit1 came with a PIC16F684 included.

    Dave

  6. #6
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default

    The '<<' and '>>' operators shift a value left or right, respectively, 0 to 15 times. The newly shifted-in bits are set to 0.
    Code:
    B0 = B0 << 3 ‘ Shifts B0 left 3 places, (same as multiply by 8)
    W1 = W0 >> 1 ‘ Shifts W0 right 1 position and places result in W1 (same as divide by 2)

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default

    Hi,
    SEROUT is for serial RS232 communication. It's just used as an example in the LOOKUP section of the manual.
    Code:
    i VAR BYTE
    Main:
      For i = 0 to 9
       LOOKUP i, [0, 6, 91, 79, 102, 109, 125, 7, 127, 103], GPIO
       Pause 500
      Next
    Goto Main
    See, when i is 0 the first value in the lookup table (0) will get written to GPIO, all bits will be reset, when i is 6 the seventh value (125) in the lookup table will get written to GPIO. 125 is the same as %01111101 which means all segments except the one driven by Bit1 will be on - the display will show "6".

    Now, this would work on a PIC with seven or more consecutive GPIO pins, which apparently doesn't exist.... Getting a PIC with a "full" PortB and using that instead of GPIO would do it. It's still possible to do on the '684 (which has 6 bits on PortA and 6 bits on PortB, no GPIO) but then maby the Lookup aproach isn't the most suitable.

    There are many many ways to skin the cat, sit down and play a bit with what you have, if you already have the BCD-Seven segment decoder go ahead and use that and play around.

    /Henrik.

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


    Did you find this post helpful? Yes | No

    Default

    In the Math Operators section of the manual take a look at SHIFT and the Btiwise Operators.

    The idea is..
    From Henrik
    To display a "2" you need to set bits 0, 1, 3, 4 and 6 (%01011011 or 91)
    You will have to connect the display so that part is on one port and part on another. half and half...
    Take the lower 4 bits in the case of #2 (1011) and send them to the display with Port1.
    Take the upper 4 bits (0101) and send that to the display with Port2.

    Think of Port1 as being 0-3
    Port2 as 4-7

    Presto... a whole Port...0-7
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Well plenty to think about today. Maybe a little consolidation from me, drum those basics into my mind (I still have plenty to learn here).

    I see what you're saying regards splitting port1 & port1 to drive the display.

    Absolutely fascinating stuff though, I think I'm hooked and I've only managed to flash a few LED's.

    Again many thanks to you all.

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    Hi everyone. I've been working on a program below which is a modification of Henrik's look up table program. I know if you had a PIC with an eight bit wide output you could store the output words in the lookup table and then drive a seven segment display directly as Henrik explained.

    So I thought I'd try and load a lookup table to blink an LED (D0) 3 times using a for-next-loop (I've never used a for-next-loop before). It works except after three cycles it doesn't stop. I read up that after the loop has finished it then moves on down to the next instruction, so I've added STOP / END. IF i = 4 then STOP. None of these work and when any of these lines are added the program only cycles once.

    The only thing I can think of is that the 12F683 doesn't support LOOKUP tables.

    Any ideas please? Dave

    ANSEL = %00000000 'disable analog select so ports work as digital i/o
    CMCON0 = %00000111 'Disable analog comparators
    TRISIO = %11001111 'Set GPIO.4&5 to input
    GPIO = %00000000 ' set all outputs low

    i VAR BYTE

    START
    Main:
    pause 500 'pause 500 mili-secs
    For i = 1 to 3 ' loop count variable (value i) also number of times to loop.
    LOOKUP i, [ 223, 223, 223] ,GPIO '223 = %11011111 D0 switches on (GPIO.4)
    Pause 500 'pause 500 mili-secs
    LOW GPIO.4 ' DO switches off
    Next i ' loop again. ONE is added to count i and prog jumps to FOR

  11. #11
    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