Back to the beginning


Closed Thread
Results 1 to 40 of 49

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: Back to the beginning

    This is an example that just does not work - OK laugh but once I get through the basics I'll be playing all night.

    ' Name : BLINKXU.pbp
    ' Compiler : PICBASIC PRO Compiler 2.6
    ' Assembler : MPASM
    ' Target PIC : PIC18F4550 or similar type
    ' Hardware : LAB-XUSB Experimenter Board
    ' Oscillator : 20MHz external
    ' Keywords : FOR NEXT
    ' Description : PICBASIC PRO program to blink an LED connected
    ' to PORTD.0 about once a second.
    '

    ' Define LOADER_USED to allow use of the boot loader.
    ' This will not affect normal program operation.


    ' RESET_ORG can be set to move the BASIC program out of the way
    ' of any boot loader running from location 0, such as the
    ' Microchip USB boot loader
    'Define RESET_ORG 800h

    #config
    _config _mclre_on & _CP_OFF & _WDT_OFF
    #endconfig


    mainloop:
    high porta.1 ' Turn on LED connected to PORTD.0 <----- SYNTAX ERROR
    Pause 500 ' Delay for .5 seconds
    Low porta.0 ' Turn off LED connected to PORTD.0
    Pause 500 ' Delay for .5 seconds
    Goto mainloop ' Go back to loop and blink LED forever

    End


    Although the comments box states that it is for a PIC18F452 the selection box on the compiler is set to 12F509.

    Even if the poor 12F509 does not have enough memory for the task in hand I shouldn't get syntax errors ?
    Last edited by AndyFreestone; - 6th April 2013 at 16:16.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default Re: Back to the beginning

    Quote Originally Posted by AndyFreestone View Post
    This is an example that just does not work - OK laugh but once I get through the basics I'll be playing all night.

    .
    .
    .

    #config
    _config _mclre_on & _CP_OFF & _WDT_OFF #endconfig


    mainloop:
    high porta.1 ' Turn on LED connected to PORTD.0 <----- SYNTAX ERROR
    Pause 500 ' Delay for .5 seconds
    Low porta.0 ' Turn off LED connected to PORTD.0
    Pause 500 ' Delay for .5 seconds
    Goto mainloop ' Go back to loop and blink LED forever

    End


    Although the comments box states that it is for a PIC18F452 the selection box on the compiler is set to 12F509.

    Even if the poor 12F509 does not have enough memory for the task in hand I shouldn't get syntax errors ?

    Doesn't compile due to your wrong CONFIG ...

    so; moreover, it can't be programmed into the chip ...

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

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


    Did you find this post helpful? Yes | No

    Default Re: Back to the beginning

    Hi,
    The PIC12F509 doesn't have a PortA and therefor no TRISA or PortA registers, so you get an error when you try to access things which are not available.

    /Henrik.

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Back to the beginning

    Thanks Henrik,

    How does PBP3 address the single port of the 12F509?

    Andy

    I, probably wrongly, assumed that it would use TRISA.

    I did try to edit the sample program for the 18F452 just to change the outputs but nothing changed. We'll leave that problem again until later.
    Last edited by AndyFreestone; - 6th April 2013 at 16:42.

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


    Did you find this post helpful? Yes | No

    Default Re: Back to the beginning

    As it does with any other register - by the registers name, which on the 12F509 is either PortB or GPIO for the actual port and TRISB or TRISGPIO for the "direction".
    You know, assumption is the mother of all f**k-ups so never assume anything - a simple look at the datasheet for the device would have told you that there is no PortA.

    /Henrik.

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: Back to the beginning

    Quote Originally Posted by HenrikOlsson View Post
    As it does with any other register - by the registers name, which on the 12F509 is either PortB or GPIO for the actual port and TRISB or TRISGPIO for the "direction".
    You know, assumption is the mother of all f**k-ups so never assume anything - a simple look at the datasheet for the device would have told you that there is no PortA.

    /Henrik.
    Again way over my current knowledge. How do I address THE PORT in PBP3 ?

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


    Did you find this post helpful? Yes | No

    Default Re: Back to the beginning

    Like I said, on the 12F509 THE PORT is named PortB or GPIO not PortA.
    Otherwise you had it right - HIGH PortB.0 or HIGH GPIO.0 instead of HIGH PortA.0

    EDIT: I'm sorry, make that GPIO.0 only, PortB was for the 12F605 only which share the same datasheet.
    Last edited by HenrikOlsson; - 6th April 2013 at 17:56.

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: Back to the beginning

    Quote Originally Posted by Acetronics View Post
    Doesn't compile due to your wrong CONFIG ...

    so; moreover, it can't be programmed into the chip ...

    Alain
    OK - how should it read ?

    I'm trying a real basic 12F509 to start with but for convenience I also have 12F629, 16F684, 16F506, 16F722 and loads of 18F45K22's
    Last edited by AndyFreestone; - 6th April 2013 at 16:39.

  9. #9
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    3,159


    Did you find this post helpful? Yes | No

    Default Re: Back to the beginning

    Quote Originally Posted by AndyFreestone View Post
    ... I also have ... loads of 18F45K22's
    This is for PBP 2.60c, so only the syntax for CONFIG changes.

    Code:
    ' PicBasic Pro program to blink all the LEDs connected to PORTD
    
    '   PIC     18F44K22 int osc
    '   PBP     v2.60c      MCS+    v2.1.0.7        U2 programmer   v4.32
    '   MPASM   v5.49       MCS     v4.0.0.0
    
    ' Define LOADER_USED to allow use of the boot loader.
    ' This will not affect normal program operation.
    
    asm
     __CONFIG    _CONFIG1H, _FOSC_INTIO67_1H & _PLLCFG_ON_1H & _PRICLKEN_ON_1H & _FCMEN_ON_1H & _IESO_OFF_1H
     __CONFIG    _CONFIG2L, _PWRTEN_ON_2L & _BOREN_SBORDIS_2L & _BORV_285_2L
     __CONFIG    _CONFIG2H, _WDTEN_OFF_2H
     __CONFIG    _CONFIG3H, _CCP2MX_PORTC1_3H & _PBADEN_OFF_3H & _CCP3MX_PORTE0_3H & _HFOFST_OFF_3H & _T3CMX_PORTB5_3H & _P2BMX_PORTC0_3H & _MCLRE_EXTMCLR_3H
     __CONFIG    _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
    endasm
    
    OSCCON  = %01111100
    OSCCON2 = %10000100
    OSCTUNE = %11000000
    
    ANSELA = %00000000          ' Set port to digital
    ANSELB = %00000000
    ANSELC = %00000000
    ANSELD = %00000000
    ANSELE = %00000000
    
    ADCON0 = %00000000          ' Disable ADC
    
    TRISD = %00000000           ' Set PORTD to all output
    
    ' Define	LOADER_USED	1
    DEFINE OSC 64
    
    i       var     byte        ' Define loop variable
    
    LEDS    var     PORTD       ' Alias PORTD to LEDS
    
        LEDS = %00000001        ' First LED on
    
    mainloop:
        For i = 1 to 7          ' Go through For..Next loop 7 times
            Pause 1000          ' Delay for 1 seconds
            LEDS = LEDS << 1    ' Shift on LED one to left
        Next i
    
        For i = 1 to 7          ' Go through For..Next loop 7 times
            Pause 1000          ' Delay for 1 seconds
            LEDS = LEDS >> 1    ' Shift on LED one to right
        Next i
    
        Goto mainloop           ' Go back to loop and blink LED forever
    End
    Robert


    EDIT: It's for a 18F44K22, but it is the smaller brother of the 18F45K22; same pinouts. I'm looking at it working right now, so it's good to go.
    Last edited by Demon; - 6th April 2013 at 18:01.

  10. #10
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default Re: Back to the beginning

    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2013 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 06/04/2013                                        *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    ' Name : BLINKXU.pbp
    ' Compiler : PICBASIC PRO Compiler 3.0' Assembler : MPASM
    ' Target PIC : PIC12F509 or similar type
    ' Hardware : LAB-XUSB Experimenter Board
    ' Oscillator : 4MHz external
    ' Keywords : FOR NEXT
    ' Description : PICBASIC PRO program to blink an LED connected 
    ' to PORTD.0 about once a second.
    '
    
    ' Define LOADER_USED to allow use of the boot loader.
    ' This will not affect normal program operation.
    
    
    ' RESET_ORG can be set to move the BASIC program out of the way
    ' of any boot loader running from location 0, such as the
    ' Microchip USB boot loader
    'Define RESET_ORG 800h
    
    #config
        __config _MCLRE_ON & _CP_OFF & _WDT_OFF
    #endconfig
    
    
    mainloop:
    high GPIO.0 ' Turn on LED connected to PORTD.0
    Pause 500 ' Delay for .5 seconds
    Low GPIO.0 ' Turn off LED connected to PORTD.0
    Pause 500 ' Delay for .5 seconds
    Goto mainloop ' Go back to loop and blink LED forever
    
    End
    this one should show 83 Words ...

    just "cut and paste" it ...
    Last edited by Acetronics2; - 6th April 2013 at 17:01.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

Similar Threads

  1. Beginning USB How to/Whats needed to use it.
    By wdmagic in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 11th April 2013, 21:11
  2. Missing chars at beginning of LCD display
    By jimbostlawrence in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 20th November 2009, 00:13
  3. 12F629 beginning
    By Davidpower in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 1st October 2007, 22:37
  4. Program returns to beginning at interupt
    By BGreen in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 25th April 2005, 11:20

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