PICBasic newbie problem


Closed Thread
Results 1 to 33 of 33

Hybrid View

  1. #1
    Join Date
    Feb 2008
    Posts
    8

    Question PICBasic newbie problem

    Dear members,

    FOA,I'm not new to the PIC World, I'm using CCS C compiler regularly

    Recently I started using PICBasic Pro because i knew basic is easy to use when it come create very simple project... you know leds stuff!

    However after reading that @ __config is depreciated for PIC18
    I'm trying to use CONFIG instead but how ?

    Code:
    CONFIG FOSC = HS,LVP = OFF,BOR = OFF,MCLRE = OFF
    
    led VAR PORTB.5
    steps VAR WORD
    cycles CON 2
    
    ' Change limits for steps to play around 0 or 100% brightness
    ' Change steps for different duration of ramps
    ' Works good even with high brightness LEDs, harder to control linearly
    
    
    fade:
    
    up:
    For steps=0 TO 255
    PWM led,steps,cycles
    Next
    High led
    
    Pause 2500
    
    down:
    For steps=255 TO 1 STEP -1
    PWM led,steps,cycles
    Next
    Low led
    
    Pause 2500
    
    
    GoTo fade
    
    End
    Microcode studio says ERROR syntax at the first line! why ?

    Yes i did read the other post, including the faq about headers but like i said __CONFIG dont work anymore with MPASM

    Best Regards,

    Laurent

    EDIT: oh btw , pic18f4550 with 12mhz hs xtal
    Last edited by ELCouz; - 7th February 2008 at 22:09.

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


    Did you find this post helpful? Yes | No

    Default

    http://ww1.microchip.com/downloads/e...Doc/39632b.pdf
    check out OSCCON and OSCTUNE see section 2.2.2, 2.2.5.2, aw heck, read all of section 2.
    Last edited by Archangel; - 8th February 2008 at 01:42.
    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.

  3. #3
    Join Date
    Feb 2008
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Yes, i have a printed pdf of this pic on my wall :P

    I did read them before , the problem is ... how to write (declare) them in PICBasic this is my first attempt at picbasic , so don't bash me :P ?

    IMPORTANT: For the PIC18 devices, the __CONFIG directive has been
    ; superseded by the CONFIG directive. The following settings
    ; are available for this device.
    ;
    ; PLL Prescaler Selection bits:
    ; PLLDIV = 1 No prescale (4 MHz oscillator input drives PLL directly)
    ; PLLDIV = 2 Divide by 2 (8 MHz oscillator input)
    ; PLLDIV = 3 Divide by 3 (12 MHz oscillator input)
    ; PLLDIV = 4 Divide by 4 (16 MHz oscillator input)
    ; PLLDIV = 5 Divide by 5 (20 MHz oscillator input)
    ; PLLDIV = 6 Divide by 6 (24 MHz oscillator input)
    ; PLLDIV = 10 Divide by 10 (40 MHz oscillator input)
    ; PLLDIV = 12 Divide by 12 (48 MHz oscillator input)
    ;
    ; CPU System Clock Postscaler:
    ; CPUDIV = OSC1_PLL2 [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
    ; CPUDIV = OSC2_PLL3 [OSC1/OSC2 Src: /2][96 MHz PLL Src: /3]
    ; CPUDIV = OSC3_PLL4 [OSC1/OSC2 Src: /3][96 MHz PLL Src: /4]
    ; CPUDIV = OSC4_PLL6 [OSC1/OSC2 Src: /4][96 MHz PLL Src: /6]
    ;
    ; USB Clock Selection bit (used in Full Speed USB mode only; UCFG:FSEN = 1):
    ; USBDIV = 1 USB clock source comes directly from the primary oscillator block with no postscale
    ; USBDIV = 2 USB clock source comes from the 96 MHz PLL divided by 2
    ;
    ; Oscillator Selection bits:
    ; FOSC = XT_XT XT oscillator, XT used by USB
    ; FOSC = XTPLL_XT XT oscillator, PLL enabled, XT used by USB
    ; FOSC = ECIO_EC External clock, port function on RA6, EC used by USB
    ; FOSC = EC_EC External clock, CLKOUT on RA6, EC used by USB
    ; FOSC = ECPLLIO_EC External clock, PLL enabled, port function on RA6, EC used by USB
    ; FOSC = ECPLL_EC External clock, PLL enabled, CLKOUT on RA6, EC used by USB
    ; FOSC = INTOSCIO_EC Internal oscillator, port function on RA6, EC used by USB
    ; FOSC = INTOSC_EC Internal oscillator, CLKOUT on RA6, EC used by USB
    ; FOSC = INTOSC_XT Internal oscillator, XT used by USB
    ; FOSC = INTOSC_HS Internal oscillator, HS used by USB
    ; FOSC = HS HS oscillator, HS used by USB
    ; FOSC = HSPLL_HS HS oscillator, PLL enabled, HS used by USB
    ;
    ; Fail-Safe Clock Monitor Enable bit:
    ; FCMEN = OFF Fail-Safe Clock Monitor disabled
    ; FCMEN = ON Fail-Safe Clock Monitor enabled
    ;
    ; Internal/External Oscillator Switchover bit:
    ; IESO = OFF Oscillator Switchover mode disabled
    ; IESO = ON Oscillator Switchover mode enabled
    ;
    ; Power-up Timer Enable bit:
    ; PWRT = ON PWRT enabled
    ; PWRT = OFF PWRT disabled
    ;
    ; Brown-out Reset Enable bits:
    ; BOR = OFF Brown-out Reset disabled in hardware and software
    ; BOR = SOFT Brown-out Reset enabled and controlled by software (SBOREN is enabled)
    ; BOR = ON_ACTIVE Brown-out Reset enabled in hardware only and disabled in Sleep mode (SBOREN is disabled)
    ; BOR = ON Brown-out Reset enabled in hardware only (SBOREN is disabled)
    ;
    ; Brown-out Voltage bits:
    ; BORV = 0 Maximum setting
    ; BORV = 1
    ; BORV = 2
    ; BORV = 3 Minimum setting
    ;
    ; USB Voltage Regulator Enable bit:
    ; VREGEN = OFF USB voltage regulator disabled
    ; VREGEN = ON USB voltage regulator enabled
    ;
    ; Watchdog Timer Enable bit:
    ; WDT = OFF HW Disabled - SW Controlled
    ; WDT = ON HW Enabled - SW Disabled
    ;
    ; Watchdog Timer Postscale Select bits:
    ; WDTPS = 1 1:1
    ; WDTPS = 2 1:2
    ; WDTPS = 4 1:4
    ; WDTPS = 8 1:8
    ; WDTPS = 16 1:16
    ; WDTPS = 32 1:32
    ; WDTPS = 64 1:64
    ; WDTPS = 128 1:128
    ; WDTPS = 256 1:256
    ; WDTPS = 512 1:512
    ; WDTPS = 1024 1:1024
    ; WDTPS = 2048 1:2048
    ; WDTPS = 4096 1:4096
    ; WDTPS = 8192 1:8192
    ; WDTPS = 16384 1:16384
    ; WDTPS = 32768 1:32768
    ;
    ; MCLR Pin Enable bit:
    ; MCLRE = OFF RE3 input pin enabled; MCLR disabled
    ; MCLRE = ON MCLR pin enabled; RE3 input pin disabled
    ;
    ; Low-Power Timer 1 Oscillator Enable bit:
    ; LPT1OSC = OFF Timer1 configured for higher power operation
    ; LPT1OSC = ON Timer1 configured for low-power operation
    ;
    ; PORTB A/D Enable bit:
    ; PBADEN = OFF PORTB<4:0> pins are configured as digital I/O on Reset
    ; PBADEN = ON PORTB<4:0> pins are configured as analog input channels on Reset
    ;
    ; CCP2 MUX bit:
    ; CCP2MX = OFF CCP2 input/output is multiplexed with RB3
    ; CCP2MX = ON CCP2 input/output is multiplexed with RC1
    ;
    ; Stack Full/Underflow Reset Enable bit:
    ; STVREN = OFF Stack full/underflow will not cause Reset
    ; STVREN = ON Stack full/underflow will cause Reset
    ;
    ; Single-Supply ICSP Enable bit:
    ; LVP = OFF Single-Supply ICSP disabled
    ; LVP = ON Single-Supply ICSP enabled
    ;
    ; Dedicated In-Circuit Debug/Programming Port (ICPORT) Enable bit:
    ; ICPRT = OFF ICPORT disabled
    ; ICPRT = ON ICPORT enabled
    ;
    ; Extended Instruction Set Enable bit:
    ; XINST = OFF Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
    ; XINST = ON Instruction set extension and Indexed Addressing mode enabled
    ;
    ; Background Debugger Enable bit:
    ; DEBUG = ON Background debugger enabled, RB6 and RB7 are dedicated to In-Circuit Debug
    ; DEBUG = OFF Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
    ;
    ; Code Protection bit Block 0:
    ; CP0 = ON Block 0 (000800-001FFFh) code-protected
    ; CP0 = OFF Block 0 (000800-001FFFh) not code-protected
    ;
    ; Code Protection bit Block 1:
    ; CP1 = ON Block 1 (002000-003FFFh) code-protected
    ; CP1 = OFF Block 1 (002000-003FFFh) not code-protected
    ;
    ; Code Protection bit Block 2:
    ; CP2 = ON Block 2 (004000-005FFFh) code-protected
    ; CP2 = OFF Block 2 (004000-005FFFh) not code-protected
    ;
    ; Code Protection bit Block 3:
    ; CP3 = ON Block 3 (006000-007FFFh) code-protected
    ; CP3 = OFF Block 3 (006000-007FFFh) not code-protected
    ;
    ; Boot Block Code Protection bit:
    ; CPB = ON Boot block (000000-0007FFh) code-protected
    ; CPB = OFF Boot block (000000-0007FFh) not code-protected
    ;
    ; Data EEPROM Code Protection bit:
    ; CPD = ON Data EEPROM code-protected
    ; CPD = OFF Data EEPROM not code-protected
    ;
    ; Write Protection bit Block 0:
    ; WRT0 = ON Block 0 (000800-001FFFh) write-protected
    ; WRT0 = OFF Block 0 (000800-001FFFh) not write-protected
    ;
    ; Write Protection bit Block 1:
    ; WRT1 = ON Block 1 (002000-003FFFh) write-protected
    ; WRT1 = OFF Block 1 (002000-003FFFh) not write-protected
    ;
    ; Write Protection bit Block 2:
    ; WRT2 = ON Block 2 (004000-005FFFh) write-protected
    ; WRT2 = OFF Block 2 (004000-005FFFh) not write-protected
    ;
    ; Write Protection bit Block 3:
    ; WRT3 = ON Block 3 (006000-007FFFh) write-protected
    ; WRT3 = OFF Block 3 (006000-007FFFh) not write-protected
    ;
    ; Boot Block Write Protection bit:
    ; WRTB = ON Boot block (000000-0007FFh) write-protected
    ; WRTB = OFF Boot block (000000-0007FFh) not write-protected
    ;
    ; Configuration Register Write Protection bit:
    ; WRTC = ON Configuration registers (300000-3000FFh) write-protected
    ; WRTC = OFF Configuration registers (300000-3000FFh) not write-protected
    ;
    ; Data EEPROM Write Protection bit:
    ; WRTD = ON Data EEPROM write-protected
    ; WRTD = OFF Data EEPROM not write-protected
    ;
    ; Table Read Protection bit Block 0:
    ; EBTR0 = ON Block 0 (000800-001FFFh) protected from table reads executed in other blocks
    ; EBTR0 = OFF Block 0 (000800-001FFFh) not protected from table reads executed in other blocks
    ;
    ; Table Read Protection bit Block 1:
    ; EBTR1 = ON Block 1 (002000-003FFFh) protected from table reads executed in other blocks
    ; EBTR1 = OFF Block 1 (002000-003FFFh) not protected from table reads executed in other blocks
    ;
    ; Table Read Protection bit Block 2:
    ; EBTR2 = ON Block 2 (004000-005FFFh) protected from table reads executed in other blocks
    ; EBTR2 = OFF Block 2 (004000-005FFFh) not protected from table reads executed in other blocks
    ;
    ; Table Read Protection bit Block 3:
    ; EBTR3 = ON Block 3 (006000-007FFFh) protected from table reads executed in other blocks
    ; EBTR3 = OFF Block 3 (006000-007FFFh) not protected from table reads executed in other blocks
    ;
    ; Boot Block Table Read Protection:
    ; EBTRB = ON Boot block (000000-0007FFh) protected from table reads executed in other blocks
    ; EBTRB = OFF Boot block (000000-0007FFh) not protected from table reads executed in other blocks
    ;
    It would be nice if i could write them (ex: FOSC = HS written in P18F4550.inc of MPASM ) instead of defining them with HEX stuff
    Have a nice day!

    Best Regards,
    Laurent

  4. #4
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Smile

    Hi Laurent,

    Welcome to the forum.
    See if this previous series of posts from Melanie, mister_e and others, helps.
    http://www.picbasic.co.uk/forum/showthread.php?p=14264

    -Adam-
    Ohm it's not just a good idea... it's the LAW !

  5. #5
    Join Date
    Feb 2008
    Posts
    8


    Did you find this post helpful? Yes | No

    Default

    Thanks I've commented the Picbasic fuses in the include...

    Fuses is ok but on compiling this code:

    Code:
    ASM
        CONFIG FOSC=HS    ; Use HS oscillator (20MHZ here)
        CONFIG BOR=OFF    ; Brown out reset ON  
        CONFIG WDT=ON    ; Watch dog timer ON
        CONFIG LVP=OFF   ; Low Voltage programming OFF
        CONFIG DEBUG=OFF ; Background debugger OFF
        ENDASM
    led VAR PORTB.5
    steps VAR WORD
    cycles CON 2
    
    ' Change limits for steps to play around 0 or 100% brightness
    ' Change steps for different duration of ramps
    ' Works good even with high brightness LEDs, harder to control linearly
    
    
    fade:
    
    up:
    For steps=0 TO 255
    PWM led,steps,cycles
    Next
    High led
    
    Pause 2500
    
    down:
    For steps=255 TO 1 STEP -1
    PWM led,steps,cycles
    Next
    Low led
    
    Pause 2500
    
    
    GoTo fade
    
    End
    i receive many errors :


    maybe it's the code that is faulty or it's something else ?

    Could you show me a code that will ABSOLUTELY compile (and tested to work), ex: blink a led so i can start to debug the previous code , to see if its my compile that freaks out or it just a simple issue....


    Many thanks!

    Have a nice week!

    Best Regards,

    Laurent

  6. #6
    Join Date
    Sep 2007
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    I just went through the same problems. See the thread below post#6 regarding editing the .inc file


    http://www.picbasic.co.uk/forum/show...ighlight=fuses
    Best Regards,

    Kurt A. Kroh
    KrohTech

    “Goodbye and thanks for all the fish”

  7. #7
    Join Date
    Sep 2007
    Posts
    50


    Did you find this post helpful? Yes | No

    Default

    Code:
    ASM
        CONFIG FOSC=HS    ; Use HS oscillator (20MHZ here)
        CONFIG BOR=OFF    ; Brown out reset ON  
        CONFIG WDT=ON    ; Watch dog timer ON
        CONFIG LVP=OFF   ; Low Voltage programming OFF
        CONFIG DEBUG=OFF ; Background debugger OFF
        ENDASM
    I never did get this method to work. I use this method of setting the fuses on my 18F2410:

    Code:
    @       __CONFIG    _CONFIG1H, _OSC_INTIO67_1H
    @       __CONFIG    _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    @       __CONFIG    _CONFIG3H, _MCLRE_OFF_3H & _PBADEN_OFF_3H 
    @       __CONFIG    _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
    Last edited by krohtech; - 8th February 2008 at 21:27.
    Best Regards,

    Kurt A. Kroh
    KrohTech

    “Goodbye and thanks for all the fish”

Similar Threads

  1. Newbie? Problem with LCD
    By lew247 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 7th December 2009, 19:48
  2. Picbasic Newbie Problem
    By Stargazer3141 in forum mel PIC BASIC
    Replies: 4
    Last Post: - 21st August 2007, 17:40
  3. Problem on writing EEPROM in Winpic800 with picbasic pro
    By selimkara in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 4th May 2007, 16:33
  4. PicBasic Pro Math Problem??
    By Glen65 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 5th March 2006, 04:36
  5. DMX & PicBasic coding problem
    By magicmarty in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 20th September 2004, 15:35

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