blinking basic


Closed Thread
Results 1 to 10 of 10

Thread: blinking basic

  1. #1

    Default blinking basic

    Hi, i have been recently given a old computer which came with some programming tools. a pickit 2 and a 44 pin demo board PIC16f887 -i/pt.

    i loaded up the lessons hex files for the board which were made in asm and had a little muck about with the leds, switch and dial.

    from lesson one i manged to change which led lit up buy changing the values of the TRISD,0 PORTD,0 from the lesson below

    #include <p16F887.inc>
    __CONFIG _CONFIG1, _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
    __CONFIG _CONFIG2, _WRT_OFF & _BOR21V

    org 0
    Start:
    bsf STATUS,RP0 ; select Register Bank 1
    bcf TRISD,0 ; make IO Pin RD0 an output
    bcf STATUS,RP0 ; back to Register Bank 0
    bsf PORTD,0 ; turn on LED RD0 (DS0)
    goto $ ; wait here
    end

    the person who gave me the computer told me to use microcode studio with the picbasic language as it will be a easy place to start.

    i found this blink guide on this forum

    define osc 4
    OSCCON = %01100001
    PORTD = 0
    TRISD = 0
    loop: PORTD.0 = 1 ' Turn on LED connected to PORTD.0
    Pause 500 ' Delay for .5 seconds

    PORTD.0 = 0 ' Turn off LED connected to PORTD.0
    Pause 500 ' Delay for .5 seconds

    Goto loop ' Go back to loop and blink LED forever
    End

    so i pasted it into microcode studio and built the hex but when loading it into pickit2 programmer it gives a warning about some configuration words not being in the hex, i still pressed write and it seems to work =)

    i was wandering where i should begin all the information i found on the net seems to be for older PICs and im a bit lost. assembly seems confusing and i was wondering if anyone knows where a good place to start picbasic would be considering the only programming i have done was on a C64 print goto run etc. =/

    well thats all i can think of now hehe but i guess i can read the info i was given.

    all help will be apricatied

    thank you

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


    Did you find this post helpful? Yes | No

    Default

    Try this
    Code:
            @   DEVICE      INTRC_OSC_NOCLKOUT, WDT_OFF,PWRT_ON,MCLR_OFF
            @   DEVICE      PROTECT_OFF, CPD_OFF,BOD_OFF
            @   DEVICE      IESO_OFF, FCMEN_OFF,LVP_OFF
            @   DEVICE2     BOR21V, WRT_OFF
          
            DEFINE OSC 4
            OSCCON = %01100001
            PORTD = 0
            TRISD = 0
    loop:   
            PORTD.0 = 1 ' Turn on LED connected to PORTD.0
            Pause 500 ' Delay for .5 seconds
            
            PORTD.0 = 0 ' Turn off LED connected to PORTD.0
            Pause 500 ' Delay for .5 seconds
            
            Goto loop ' Go back to loop and blink LED forever
            End
    Also, have a look at this link.
    http://www.picbasic.co.uk/forum/showthread.php?t=543

    HTH
    Last edited by mister_e; - 1st February 2009 at 21:27.
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default

    If you use MPASM as assembler, you can use the line in your ASM code at the top, but still followi the instruction in post #5 i Posted above.

    Code:
    @    __CONFIG _CONFIG1, _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
    @    __CONFIG _CONFIG2, _WRT_OFF & _BOR21V
    Steve

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

  4. #4


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Try this
    Code:
            @   DEVICE      INTRC_OSC_NOCLKOUT, WDT_OFF,PWRT_ON,MCLR_OFF
            @   DEVICE      PROTECT_OFF, CPD_OFF,BOD_OFF
            @   DEVICE      IESO_OFF, FCMEN_OFF,LVP_OFF
            @   DEVICE2     BOR21V, WRT_OFF
          
            DEFINE OSC 4
            OSCCON = %01100001
            PORTD = 0
            TRISD = 0
    loop:   
            PORTD.0 = 1 ' Turn on LED connected to PORTD.0
            Pause 500 ' Delay for .5 seconds
            
            PORTD.0 = 0 ' Turn off LED connected to PORTD.0
            Pause 500 ' Delay for .5 seconds
            
            Goto loop ' Go back to loop and blink LED forever
            End
    Also, have a look at this link.
    http://www.picbasic.co.uk/forum/showthread.php?t=543

    HTH
    thanks i have read a little about configs but still unclear i guess the link will explain more also i pasted your code had the same error as before but code works fine, also this popped up while building


    also forgot to mention this is all new to me i haven't created my own code yet i don't know what the variables, configs and commands are and what they can do for any PIC let alone my 44 16f887 demo board ;x
    Attached Images Attached Images  
    Last edited by loyalty_card; - 1st February 2009 at 21:46.

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


    Did you find this post helpful? Yes | No

    Default

    The error you have is because you're using MASm as assembler, so just replace all @ DEVICE line with those i've posted one post before.
    Steve

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

  6. #6


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    The error you have is because you're using MASm as assembler, so just replace all @ DEVICE line with those i've posted one post before.
    thank you for making the code look tidy

    but i still get an warning error in the programmer and now only 1 error after building

    error[118] projectpath.asm 52: overwriting previous address contents (2007)

    Code:
    @    __CONFIG _CONFIG1, _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
    @    __CONFIG _CONFIG2, _WRT_OFF & _BOR21V
          
            DEFINE OSC 4
            OSCCON = %01100001
            PORTD = 0
            TRISD = 0
    loop:   
            PORTD.0 = 1 ' Turn on LED connected to PORTD.0
            Pause 500 ' Delay for .5 seconds
            
            PORTD.0 = 0 ' Turn off LED connected to PORTD.0
            Pause 500 ' Delay for .5 seconds
            
            Goto loop ' Go back to loop and blink LED forever
            End
    so using picbasic still uses asm code? my compiler is set c:/pbp shall i uncheck the use mpasm assembly

    also im thinking to order this book ;o

    30 Projects Using PIC BASIC and PIC BASIC PRO

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


    Did you find this post helpful? Yes | No

    Default

    As I said go to this link
    http://www.picbasic.co.uk/forum/showthread.php?t=543

    Look post #5

    And no, don't switch to PM assembler, it just don't worth it.

    You'll see it's pretty easy once you catch it.
    Last edited by mister_e; - 1st February 2009 at 22:24.
    Steve

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

  8. #8


    Did you find this post helpful? Yes | No

    Default

    thanks you have been helpfull i will post again when i have something cool to show =)

  9. #9


    Did you find this post helpful? Yes | No

    Default

    and another person hooked on pics

  10. #10
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by nomad View Post
    and another person hooked on pics
    Which is a heck of a lot better than . . . being picked, on hooks.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

Similar Threads

  1. PIC BASIC TLC5940 code
    By eletrokat in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th May 2010, 21:01
  2. Indexer not indexing...a basic PBP problem??
    By jellis00 in forum General
    Replies: 8
    Last Post: - 24th March 2009, 16:53
  3. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  4. Replies: 5
    Last Post: - 17th January 2006, 19:26
  5. vb6 to pic basic
    By Darrenmac in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 19th December 2005, 01:56

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts