12f675_fuse_about_to_blow! - Page 2


Closed Thread
Page 2 of 24 FirstFirst 12345612 ... LastLast
Results 41 to 80 of 929
  1. #41
    Join Date
    Feb 2010
    Location
    I live in the UK
    Posts
    562


    Did you find this post helpful? Yes | No

    Default

    The 12F683's arrived today! I didn't order them until late last night, talk about service, I love the internet....:-)

    I changed the 12F675 PIC over to a 12F683 and it ran your program a treat.

    I've got a lot to learn still, a huge amount but really enjoying it.

    My first project (I'm getting ahead of myself here I know) but my first project will be to make a 12F683 OUTPUT binary coded decimal four bit words and drive a seven segment display. I figure with the 12F683 having six outputs this is a viable project.

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    "I like it when someone wants to learn.
    I will be here...."

    Thanks for that mackrackit I appreciate it. I hope I don't drive you insane during my learning curve.....!

    I'm off to bed now to dream of TRISO's.......

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    My first project (I'm getting ahead of myself here I know) but my first project will be to make a 12F683 OUTPUT binary coded decimal four bit words and drive a seven segment display. I figure with the 12F683 having six outputs this is a viable project.
    Well....
    I hate to tell you this but I think there is something wrong with your counting...
    Or mine
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Hi LEDDave,
    16F628A might be easier to drive 7 segment as no driver translator chip required ( because it has enough ports ). Your biggest challange will be due to 31 lines of code limitation, in the Demo program.
    I do not know if assembly code is counted in that limitation.
    If you have that problem I am sure Mackrackit and I would compile a few programs for you, enough so you believe this compiler is worth it's price.
    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.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Hi LEDDave,
    16F628A might be easier to drive 7 segment as no driver translator chip required ( because it has enough ports ). Your biggest challange will be due to 31 lines of code limitation, in the Demo program.
    I do not know if assembly code is counted in that limitation.
    If you have that problem I am sure Mackrackit and I would compile a few programs for you, enough so you believe this compiler is worth it's price.
    Yup, I will help.
    Problem is, I can not find a "large" PIC that will work with the demo and the PICkit1. (14 pins)
    So LEDDave may have to get a 16F676 and one of us build the hex for that...
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Yup, I will help.
    Problem is, I can not find a "large" PIC that will work with the demo and the PICkit1. (14 pins)
    So LEDDave may have to get a 16F676 and one of us build the hex for that...
    I know nothing about the PICKit1, can you use ICSP with it ?
    OK I just looked at AN258 http://www.microchip.com/stellent/id...pnote=en012103
    and it clearly shows PICKit1 using ICSP so he can go OFF BOARD with some jumper wires and program chips.
    So is it that the PICKit1 firmware does not support bigger chips ?
    This will work, until he get's serious. http://cgi.ebay.com/Microchip-PIC-JD...item1e595bbf81
    Probably Won't do 18Fs but will do nearly all 16F & 12F series.
    Last edited by Archangel; - 19th February 2010 at 06:55.
    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.

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


    Did you find this post helpful? Yes | No

    Default

    An adapter can be made for the socket, but the PICs supported are limited.
    http://www.microchip.com/stellent/id...cName=en010053
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Feeling rather pleased with myself this afternoon.

    I looked at the diode array diagram in my PICkit1 and the program mackrackit had written for me to run D0 - D1 - D2 in sequence and thought I'd like to add D3. So after much head scratching (believe me) I can up with this:

    ANSEL = %00000000
    CMCON0 = %00000111

    START:
    'D0 HIGH
    TRISIO = %11001111
    GPIO = %00010000
    PAUSE 500
    'D1 HIGH
    TRISIO = %11001111
    GPIO = %00100000
    PAUSE 500
    'D2 HIGH
    TRISIO = %11101011
    GPIO = %00010000
    PAUSE 500
    'D3 HIGH
    TRISIO = %11101011
    GPIO = %00000100
    PAUSE 500
    GOTO START

    The D3 bits mine:-) So I compiled it, no errors and whoosh: D0-D1-D2-D3 chugging along in a nice line and not a hint of burning smoke anywhere.

    I know it's only a small step, but still really pleased. I'm going to read and try to fully understand the GPIO / TRISIO port register relationship over the weekend. Still much to learn but Rome wasn't built and all that....!

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    COOL!!!!
    Progress...

    About future programmers.. I would recommend the PicKit2 over anything else. It is a bit more expensive but worth it.
    http://www.microchipdirect.com/produ...words=PG164120

    In my shop I have a PicKit1, PicStart+, and two PicKit2's. Guess the ones that get used the most..

    I will sometimes build a JDM type circuit into a project if it is something the customer may have to update and they work OK and I have a board I make for kids to learn the basics on so they do have their place but...

    Just my opinion... not trying to start a programmer war.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    I do like the PICKit with it's USB connection, early days but I think I'll stick with them for sure.

    I've a lot of basics to learn in the meantime, any thoughts on how I should structure my learning?

    I'd like to learn how to program the 12F683 to output a binary pattern (xxxx-bin) when a button gets pressed.

    Another thing I'm wondering, does the basic principles of one PIC transfer to others (I'm guessing yes, why re-invent the wheel every time) so learning the 683 chip would be a good place to start for a knowledge base.

    Question after question from me at the moment, I do apologize for that.

    Interesting stuff these PIC's, I can't wait to get a reasonable working knowledge.

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    Just a thought here.

    Is there a book on programming in PBP basic?

  12. #52
    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
    Feeling rather pleased with myself this afternoon.
    As well you should be. This is a rewarding hobby. I think you will find much pleasure in it.


    Quote Originally Posted by LEDave View Post
    Just a thought here.

    Is there a book on programming in PBP basic?
    There are lot's of them, the thing is, before you buy, hang out here and learn what they do not tell you first, then get the books and you can make what they teach work. What they do not really tell you, is how to make configs work, this is only important if you want your code to work some books do not bother to explain Port and TrIS register settings, and spend 12 chapters explaining how to install MPASM. Others are so old, they are explaining how to use 16C series, most use 16F84. There is a reason for that. 16F84 has nearly no bells and whistles, and consequently no special function registers like ANSEL, CMCON, CMCON1,CMCON0 ADCON PCON . . . . Easier for the beginner, but at a cost, old chips cost more. John Iovine has a few PBP books and his are not too bad, above exclusions aside. Chuck Hellebuyck, I think has a couple, and you MAY be able to order with a PICKIT2 with demo board, though I am not positive about that. Correct me if wrong Chuck. There ARE others, but I would probably try those first. Still waiting for BRUCE's book, I betcha it will be great, and I am sure HE won't forget to explain the configs either.
    Last edited by Archangel; - 19th February 2010 at 23:47.
    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.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    COOL!!!!
    Progress...

    About future programmers.. I would recommend the PicKit2 over anything else. It is a bit more expensive but worth it.
    http://www.microchipdirect.com/produ...words=PG164120

    In my shop I have a PicKit1, PicStart+, and two PicKit2's. Guess the ones that get used the most..

    I will sometimes build a JDM type circuit into a project if it is something the customer may have to update and they work OK and I have a board I make for kids to learn the basics on so they do have their place but...

    Just my opinion... not trying to start a programmer war.
    Ha, no war, I paid 8 bucks for my first JDM, that's why I bought it. It works, but I prefer MY PICKit2 over it. I think as cheap as they are it is worthwhile to have as a backup.
    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.

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


    Did you find this post helpful? Yes | No

    Default

    Another thing I'm wondering, does the basic principles of one PIC transfer to others (I'm guessing yes, why re-invent the wheel every time) so learning the 683 chip would be a good place to start for a knowledge base.
    Yes, pretty much all are the same. Some of the registers are different but once you learn one or two chips... The 683 is fine for learning. When you get a full copy of PBP give the 16F676 a try for the next one.
    Question after question from me at the moment, I do apologize for that.
    Ask all of the questions you want. That is what the forum is for. Several come here looking for a copy/paste solution. You are not so ask away.
    I've a lot of basics to learn in the meantime, any thoughts on how I should structure my learning?
    Do not buy any books!!!! Exception would be the one Bruce is working on.
    I will try to be nice, but the bozos currently with PBP books are just robbing newbees. They basically copy the PBP manual and some of the examples from Melabs web site. If one of the authors started posting here like Bruce does then I would have a different out look. For now I will say they are trying to make a fast buck.
    The only place to get real info on PBP is from this forum and the folks like Darrel, Bruce and Melanie.

    You are on the right track.
    Start with "blinky" then move on to push buttons. Basic I/Os.
    The PICkit1 is forcing you to learn about TRIS so that is covered. Try making the LEDs on that board do what you want with HIGH/LOW commands...

    Next would be LOOPS. FOR/NEXT WHILE/WEND, flow control.

    Then work on some simple serial stuff, have to have a way to "talk" to your chip.
    Start with SERIN2/SEROUT2. Send data to a PC to display on a terminal. The send data to the chip that would replace a button.

    Then start playing with on-board ADC and other hardware things.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Thanks for that you two, I really appreciated your help and offers of future help.

    I guess part of my problem is I'm not strong in any one area. The last time I did any programming in Basic was using my ZX Spectrum (that dates me lol) and my electronic knowledge is pretty basic and patchy. That said I'm very interested and willing to spend time trying to learn.

    It'll be interesting to see how I get on, hey in a few Months a Year or two people could be saying "If LEDave can do it there's hope for anyone".

    So: More studying of TRISIO / GPIO followed by HIGH / LOW then a LOOP then a push button..........!

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    This has taken me ages, it's a modification to Joe's program he posted earlier in the thread (with some of mackrackit's mixed in for good measure) plus some of mine.

    The thing is this: Is this a valid program in that GPIO.4 goes high & low and lights the LED due to the: THEN GPIO.4 = 1 / LET GPIO.4 = 0 program statements? I'm not sure if I've made another little bit of progress here, or just lucked in (the right LED does blink).

    When you guys have a minute could you check it out please.

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

    main:
    PAUSE 3000
    IF GPIO.5 = 0 THEN GPIO.4 = 1 'turn it on by making pin 4 high +5V
    pause 500
    LET GPIO.4 = 0 'turn it off: Pin 4 goes low 0V
    goto main ' Loop

    end

    Cheersave
    Last edited by LEDave; - 21st February 2010 at 19:37.

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


    Did you find this post helpful? Yes | No

    Default

    Good Morning Dave,
    I machine a LOT of magnesium, which is done dry. Here is the code for
    a little device to keep the chips away. It is presently ported to your
    PICKit1 (Thanks BRUCE !). This will flash D7 on your board according to how you adjust the little Pot .
    Code:
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF 
    '   *   *   *   *   * PIC12F675 *   *   *   *   * PICKit 1 Demo board
        PCON = %00000011    ' BOD off, No POR flag set
    DEFINE  NO_CLRWDT 1
    DEFINE  ADC_CLOCK 1
    
        OSCCAL = %1111100   ' SET OSC TO MAXIMUM SET OSC TO 4 MHZ INTERNAL
        CMCON   = 7	        ' Disable Analog Comparators
        ANSEL   = 1         ' Disable A/D module, all digital except AN 0
        WPU.4 = 0           ' Disable weak pull up on GPIO.4
        
        B0    VAR word         ' Byte holds 0 - 255 Word 0 - 65535
        
        
        OPTION_REG = %11111111 ' Dis/Enable internal pull-ups Bit 7
                               ' Bits 0-2 prescaler 
                               ' Bit 3 prescaler assignment 1 = WDT 0 = TMR0
                               ' Bit 4 TMR0 source edge select bit
                               ' 1 trigger on High to Low 
                               ' 0 trigger on Low to High
                               ' Bit 5 TOCS TMR0 clock source select
                               ' 1 = transition on GP2
                               ' 0 = internal clock (CLKOUT)
                               ' Bit 6 INTEDG Interrupt Edge Select
                               ' 1 = Interrupt on rising edge GP2
                               ' 0 = Interrupt on falling edge GP2
                               ' Bit 7 Pullup resistor enable bit
                               ' 1 = disabled 0 = enabled by individual port 
                               ' latch values.
    
    
        
    
        
    Main:
    Adcin 0,B0
    b0 = (b0 * 10)
    gpio.2 = 0
    TRISIO = %11111001
    GPIO.1 = 1
    pause B0
    GPIO.1 = 0
    pause 500 
        
    GOTO Main
    
        END
    you should be able to compile with the demo version, you have. Configs set for MPASM Assembler.
    Last edited by Archangel; - 22nd February 2010 at 05:17.
    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.

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


    Did you find this post helpful? Yes | No

    Default

    Here is some code to do most of what your pic was originally programmed to do.
    I think it will run on the demo, if it is too long then just comment out the last couple of statements in the main.
    Code:
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
    'DEFINE OSC 4
    'DEFINE ADC_CLOCK 1
    'OSCCAL=%10000000
    'GPIO = 0 ' set all outputs low
    TRISIO = %00000001 'Set GPIO.0 to input
    cmcon = 7 'Disable analog comparators
    ANSEL = 1 
    'PCON =  %00000011    ' Bit 0 BOD 0=on 1=off bit 1 POR 0=on 1=off
    ADCON0 =%00000011   ' SET CHANNEL 0 RT JUSTIFIED VREF - VDD
                        ' BIT 7 1 LT JUSTIFY 0 RT JUSTIFY
                        ' BIT 6 1 = VREF 0 = VDD
                        ' BIT 5:4 UNIMPLEMENTED
                        ' BIT 3:2 00 CH 0
                        '         01 CH 1
                        '         10 CH 2
                        '         11 CH 3
    
    
    DELAY VAR WORD
    
    main:
    ADCIN 0,DELAY
    DELAY = (DELAY * 4)
    TRISIO = %11111001
    GPIO   = %00000010 'LED 7 ON
    PAUSE DELAY
    GPIO   = %00000100  'LED 6 ON
    PAUSE DELAY
    TRISIO = %11011011
    GPIO   = %00000100  'LED  5 ON
    PAUSE DELAY
    GPIO   = %00100000  'LED4 ON
    PAUSE DELAY
    ADCIN 0,DELAY       ' RECHECK A/D AND RECALIBRATE
    DELAY = (DELAY * 4)
    TRISIO = %11101011
    GPIO   = %00000100  ' led 3 ON
    PAUSE DELAY
    GPIO   = %00010000   'led 2 ON
    PAUSE DELAY
    TRISIO = %11001111
    GPIO   = %00100000
    PAUSE DELAY
    GPIO   = %00010000
    'PAUSE DELAY
    goto main
    After you play with these you may be ready to order PBP. Then you can UnComment the rest of this code.
    Last edited by Archangel; - 22nd February 2010 at 05:15.
    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.

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


    Did you find this post helpful? Yes | No

    Default

    Hi Joe

    Thanks for the two programs, I'm having problems running them though. They won't won't compile in Micro code studio without errors. I'm guessing the first program won't because it's for the 12F675 which isn't supported. I did try and copy-paste them into MPL-Labs-IDE I'm so hopeless I couldn't even do that!

    Could you post up the HEX code files please and I'll see if they run.

    I must say though that parts of the programs are beyond me at present (although I do recognise a lot of the terms contained within) I'm still learning to walk as it were. I will get there though. I might not be the brightest diamond in the tiara but I am persistent....lol.

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    Here's tonight efforts. Two programs that do exactly the same thing only differently, namely flash LED 'D0' on the PICkit1. One prog using: TRISIO/GPIO/HIGH/LOW the other using: OUTPUT statements.


    If anyone would care to comment on the accuracy of what I'm doing / saying it would be much appreciated: Dave


    PROG 1:

    ANSEL = %00000000
    CMCON0 = %00000111
    TRISIO = %11001111
    GPIO = %11011111

    Start
    main
    PAUSE 500 ' wait 500mili_secs
    HIGH GPIO.4 ' 'D0' HIGH turns LED-ON +5 volts
    PAUSE 500 ' wait 500mili_secs
    LOW GPIO.4 ' 'DO' LOW turns LED-OFF zero volts
    goto MAIN ' start all over again

    ---------------------------------------------------------------------
    PROG 2:

    ANSEL = %00000000
    CMCON0 = %00000111
    OUTPUT GPIO.4 ' Makes GPIO an output
    LOW GPIO.5 ' Makes GPIO.5 zero volts

    Start
    main
    PAUSE 500 ' wait 500mili_secs
    HIGH GPIO.4 ' 'D0' HIGH turns LED-ON +5 volts
    PAUSE 500 ' wait 500mili_secs
    LOW GPIO.4 ' 'DO' LOW turns LED-OFF
    goto MAIN ' start all over again
    Last edited by LEDave; - 22nd February 2010 at 22:11.

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


    Did you find this post helpful? Yes | No

    Default

    That is the best way to learn, try things.

    Let us know the results
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    Hi mackrackit.

    Both the programs work and do the same thing. Thing is are these programs accurate? Because I don't fully understand what I'm doing (yet) I'm assuming they are because they work. I just have that nagging feeling I've lucked in again.

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    I just have that nagging feeling I've lucked in again.
    I know what you mean...
    I feel the same way when my code works

    If they work they are "accurate". There is always more than one way to do anything. With MCUs we try to find the way that uses the least amount of code space, but that will come.

    The test board you have is a little different than what most people use(I do not hear of many here using the PICkit1) so you have to do things just a bit differently. Every LED you want to turn on you have to deal with two pins. One HIGH and one LOW. To turn on some of the LEDs you will also have to make a third pin an INPUT.

    So now try to do the sequence LEDs 1-3 using HIGH/LOW. You will see what I mean.

    Another thing about the HIGH/LOW commands. They over ride the TRIS settings.
    Dave
    Always wear safety glasses while programming.

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


    Did you find this post helpful? Yes | No

    Default

    "The test board you have is a little different than what most people use (I do not hear of many here using the PICkit1)"

    What do most on here use?

    "So now try to do the sequence LEDs 1-3 using HIGH/LOW. You will see what I mean."

    Tomorrow's challenge....!

    "Every LED you want to turn on you have to deal with two pins. One HIGH and one LOW. To turn on some of the LEDs you will also have to make a third pin an INPUT."

    It is strange (to me anyway) how Microchip have configured the LED's on the PICkit1.

    I'm off to bed now, see you tomorrow.

    Dave

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by LEDave View Post
    "The test board you have is a little different than what most people use (I do not hear of many here using the PICkit1)"

    What do most on here use?
    I use the PICkit2, and my first learning platforms were Microchips "low pin count demo board" (16F690) and "44-pin demo board" (16F887). The 44-pin demo kit also came with 2 extra bare boards for experimenting with other 44 pin chips. (If you don't mind soldering TQFP parts)

    steve

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Good Morning Dave,
    I machine a LOT of magnesium, which is done dry. Here is the code for
    a little device to keep the chips away. It is presently ported to your
    PICKit1 (Thanks BRUCE !). This will flash D7 on your board according to how you adjust the little Pot .
    Code:
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF 
    '   *   *   *   *   * PIC12F675 *   *   *   *   * PICKit 1 Demo board
        PCON = %00000011    ' BOD off, No POR flag set
    DEFINE  NO_CLRWDT 1
    DEFINE  ADC_CLOCK 1
    
        OSCCAL = %1111100   ' SET OSC TO MAXIMUM SET OSC TO 4 MHZ INTERNAL
        CMCON   = 7	        ' Disable Analog Comparators
        ANSEL   = 1         ' Disable A/D module, all digital except AN 0
        WPU.4 = 0           ' Disable weak pull up on GPIO.4
        
        B0    VAR word         ' Byte holds 0 - 255 Word 0 - 65535
        
        
        OPTION_REG = %11111111 ' Dis/Enable internal pull-ups Bit 7
                               ' Bits 0-2 prescaler 
                               ' Bit 3 prescaler assignment 1 = WDT 0 = TMR0
                               ' Bit 4 TMR0 source edge select bit
                               ' 1 trigger on High to Low 
                               ' 0 trigger on Low to High
                               ' Bit 5 TOCS TMR0 clock source select
                               ' 1 = transition on GP2
                               ' 0 = internal clock (CLKOUT)
                               ' Bit 6 INTEDG Interrupt Edge Select
                               ' 1 = Interrupt on rising edge GP2
                               ' 0 = Interrupt on falling edge GP2
                               ' Bit 7 Pullup resistor enable bit
                               ' 1 = disabled 0 = enabled by individual port 
                               ' latch values.
    
    
        
    
        
    Main:
    Adcin 0,B0
    b0 = (b0 * 10)
    gpio.2 = 0
    TRISIO = %11111001
    GPIO.1 = 1
    pause B0
    GPIO.1 = 0
    pause 500 
        
    GOTO Main
    
        END
    you should be able to compile with the demo version, you have. Configs set for MPASM Assembler.
    Here is the hex:
    Code:
    :020000040000FA
    :1000000052280F39A0000310A00DA00D1F08E039E1
    :10001000200401389F000030A100323023209F14BB
    :100020009F181028A1011E084D28A301A200FF302F
    :10003000A207031CA307031C4D280330A100DF30D7
    :1000400023201728A101E83EA000A109FC30031CD1
    :100050002C28A00703182928A0070000A10F292891
    :1000600020183228A01C362800003628080010303E
    :10007000A800A101A001A70CA60C031C452822087A
    :10008000A00723080318230FA107A10CA00CA50C9F
    :10009000A40CA80B3B2824084D28831303138312B8
    :1000A00000000800831603308E007C30900083121D
    :1000B00007309900831601309F001512FF30810030
    :1000C000831200300120B8002108B9003808A600CA
    :1000D0003908A7000A30A200A3013720B80025087C
    :1000E000B90005118316F93085008312851439088B
    :1000F000A3003808162085100130A300F430162024
    :0601000061286300812864
    :02400E00D43F9D
    :00000001FF
    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.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Here is some code to do most of what your pic was originally programmed to do.
    I think it will run on the demo, if it is too long then just comment out the last couple of statements in the main.
    Code:
    @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
    'DEFINE OSC 4
    'DEFINE ADC_CLOCK 1
    'OSCCAL=%10000000
    'GPIO = 0 ' set all outputs low
    TRISIO = %00000001 'Set GPIO.0 to input
    cmcon = 7 'Disable analog comparators
    ANSEL = 1 
    'PCON =  %00000011    ' Bit 0 BOD 0=on 1=off bit 1 POR 0=on 1=off
    ADCON0 =%00000011   ' SET CHANNEL 0 RT JUSTIFIED VREF - VDD
                        ' BIT 7 1 LT JUSTIFY 0 RT JUSTIFY
                        ' BIT 6 1 = VREF 0 = VDD
                        ' BIT 5:4 UNIMPLEMENTED
                        ' BIT 3:2 00 CH 0
                        '         01 CH 1
                        '         10 CH 2
                        '         11 CH 3
    
    
    DELAY VAR WORD
    
    main:
    ADCIN 0,DELAY
    DELAY = (DELAY * 4)
    TRISIO = %11111001
    GPIO   = %00000010 'LED 7 ON
    PAUSE DELAY
    GPIO   = %00000100  'LED 6 ON
    PAUSE DELAY
    TRISIO = %11011011
    GPIO   = %00000100  'LED  5 ON
    PAUSE DELAY
    GPIO   = %00100000  'LED4 ON
    PAUSE DELAY
    ADCIN 0,DELAY       ' RECHECK A/D AND RECALIBRATE
    DELAY = (DELAY * 4)
    TRISIO = %11101011
    GPIO   = %00000100  ' led 3 ON
    PAUSE DELAY
    GPIO   = %00010000   'led 2 ON
    PAUSE DELAY
    TRISIO = %11001111
    GPIO   = %00100000
    PAUSE DELAY
    GPIO   = %00010000
    'PAUSE DELAY
    goto main
    After you play with these you may be ready to order PBP. Then you can UnComment the rest of this code.
    Here is this hex:
    Code:
    :020000040000FA
    :1000000052280F39A0000310A00DA00D1F08E039E1
    :10001000200401389F000030A100323023209F14BB
    :100020009F181028A1011E084D28A301A200FF302F
    :10003000A207031CA307031C4D280330A100DF30D7
    :1000400023201728A101E83EA000A109FC30031CD1
    :100050002C28A00703182928A0076400A10F29282D
    :1000600020183228A01C362800003628080010303E
    :10007000A800A101A001A70CA60C031C452822087A
    :10008000A00723080318230FA107A10CA00CA50C9F
    :10009000A40CA80B3B2824084D28831303138312B8
    :1000A0006400080083168030900083128501831657
    :1000B00001308500831207309900831601309F00BC
    :1000C00003308E00831203309F0000300120B800FF
    :1000D0002108B9003808A6003908A7000430A2009A
    :1000E000A3013720B8002508B9008316F930850030
    :1000F0008312023085003908A30038081620043026
    :1001000085003908A300380816208316DB308500E7
    :100110008312043085003908A300380816202030E7
    :1001200085003908A3003808162000300120B800E7
    :100130002108B9003808A6003908A7000430A20039
    :10014000A3013720B8002508B9008316EB308500DD
    :100150008312043085003908A300380816201030B7
    :1001600085003908A300380816208316CF30850093
    :100170008312203085003908A3003808162010307B
    :1001800085003908A3003808162065286300C628B2
    :02400E00DC3F95
    :00000001FF
    I uncommented that which was commented.
    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.

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


    Did you find this post helpful? Yes | No

    Default

    It is strange (to me anyway) how Microchip have configured the LED's on the PICkit1.
    In the long run you will be happy that you are learning on the PICkit1. Many do not learn about TRIS until something does not work. Another nice thing about the LEDs this way is that 8 LEDs can be controlled with 4 pins from the PIC.
    Dave
    Always wear safety glasses while programming.

  29. #69
    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

  30. #70
    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 18:07.

  31. #71
    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

  32. #72
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    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.

  33. #73
    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

  34. #74
    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.

  35. #75
    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.

  36. #76
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    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.

  37. #77
    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

  38. #78
    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 15:04.

  39. #79
    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.

  40. #80
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    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  

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