Started using PICBasic Pro 2.46


Closed Thread
Results 1 to 10 of 10
  1. #1
    Qacer's Avatar
    Qacer Guest

    Question Started using PICBasic Pro 2.46

    Hi all,

    So after reading through some literature, I decided to start playing with the PICBasic Pro compiler and a PICKit 1 programmer on a 12F675. I'm using MPLAB and have the following simple code:

    TRISIO = %001000
    GPIO = %110111

    I compiled and programmed the device, but when I view the Special Functions Register, it says that TRISIO and GPIO are 0x00.

    Can anyone help?

    Thanks!

  2. #2
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    The question that first springs to mind is... "How do you know if your PIC actually ran"?

    I always say that like a car engine, a PIC needs three things to run. Whilst a car needs fuel air and a spark, a PIC needs CLOCK, MCLR and VOLTS. I'll assume you got the VOLTS bit correct, so that leaves CLOCK and MCLR.

    How have you arranged the OSCILLATOR and MCLR settings of your 12F675 as nothing you've posted hints at this arrangement.

    Next a simple error, it won't affect your PIC's running, but you'll notice that GP.3 is an INPUT ONLY pin on this PIC. You've set TRISIO correctly by indicating it's an INPUT, but you then go and spoil it by setting GPIO as an output.

    Try this simple piece of code...
    Code:
    	'
    	'	PIC Defines
    	'	-----------
    	@ DEVICE pic12F675, INTRC_OSC_NOCLKOUT
    		' System Clock Options (Internal)	
    	@ DEVICE pic12F675, WDT_ON
    		' Watchdog Timer
    	@ DEVICE pic12F675, PWRT_ON
    		' Power-On Timer
    	@ DEVICE pic12F675, MCLR_OFF
    		' Master Clear Options (Internal)
    	@ DEVICE pic12F675, BOD_ON
    		' Brown-Out Detect
    
    	'
    	'	Hardware Defines
    	'	----------------
    	LED var GPIO.0
    
    	'
    	'	Initialise
    	'	----------
    	TRISIO=%00001000
    	CMCON=%00000111
    	ANSEL=%00000000
    
    	'
    	'	Program Body
    	'	------------
    Loop:
    	Toggle LED
    	Pause 500
    	Goto Loop
    
    	End
    You may compile this with the command line...

    PBP -p12F675 myprog -v

    Your PIC should work and toggle GPIO.0 pin at approximately 1Hz. You need do nothing else besides apply VOLTS and now MCLR and CLOCK will be taken care of internally. Go look at my usage of CMCON and ANSEL in the appropriate chapters of the PICs DATASHEET to discover why I have used them and for what purpose.

  3. #3
    Qacer's Avatar
    Qacer Guest


    Did you find this post helpful? Yes | No

    Question

    Thank you very much, Melanie! I will try the code as soon as I get my system setup. I guess I was a bit confused with the TRISIO and GPIO registers. I had the though that TRISIO was used to turn the GPIO pins into input or output and that the GPIO disables or enables the pin. Am I misinformed?

  4. #4
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    You are correct in what you say... but GPIO = %110111 would set all pins High except GPIO.3 which (if it were an output) set that Low. Writing to GPIO.3 is kinda non-productive. Naturally, none of this would work unless you first disable the onboard comparators and ADC's which is where CMCON and ANSEL come in.

  5. #5
    Qacer's Avatar
    Qacer Guest


    Did you find this post helpful? Yes | No

    Talking

    Ahh, thanks for the enlightment, Melanie. I think I did not disable the comparators and ADC. I naturally assumed that GPIO would default to general purpose inputs/outputs.

  6. #6
    Qacer's Avatar
    Qacer Guest


    Did you find this post helpful? Yes | No

    Question

    Hi again, Melanie.

    I tried the following code:


    @ DEVICE pic12F675, INTRC_OSC_NOCLKOUT
    ' System Clock Options (Internal)
    @ DEVICE pic12F675, WDT_ON
    ' Watchdog Timer
    @ DEVICE pic12F675, PWRT_ON
    ' Power-On Timer
    @ DEVICE pic12F675, MCLR_OFF
    ' Master Clear Options (Internal)
    @ DEVICE pic12F675, BOD_ON
    ' Brown-Out Detect

    CMCON=%00000111
    ANSEL=%00000000
    TRISIO=%00001000


    GPIO = %00111111


    I used MPLAB v7.30 and followed the meLabs instructions in setting up PICBasic for this software.

    When I compiled the code, I got the following error:

    Executing: "C:\pbp\PBPW.EXE" -ampasmwin -oq -z -p12F675 "test.bas"
    PicBasic Pro Compiler 2.46, (c) 1998, 2005 microEngineering Labs, Inc.
    All Rights Reserved.
    Warning[207] C:\TEMP\TEST\TEST.ASM 68 : Found label after column 1. (DEVICE)
    Error[122] C:\TEMP\TEST\TEST.ASM 68 : Illegal opcode (pic12F675)
    Warning[207] C:\TEMP\TEST\TEST.ASM 76 : Found label after column 1. (DEVICE)
    Error[122] C:\TEMP\TEST\TEST.ASM 76 : Illegal opcode (pic12F675)
    Warning[207] C:\TEMP\TEST\TEST.ASM 84 : Found label after column 1. (DEVICE)
    Error[122] C:\TEMP\TEST\TEST.ASM 84 : Illegal opcode (pic12F675)
    Warning[207] C:\TEMP\TEST\TEST.ASM 92 : Found label after column 1. (DEVICE)
    Error[122] C:\TEMP\TEST\TEST.ASM 92 : Illegal opcode (pic12F675)
    Warning[207] C:\TEMP\TEST\TEST.ASM 100 : Found label after column 1. (DEVICE)
    Error[122] C:\TEMP\TEST\TEST.ASM 100 : Illegal opcode (pic12F675)
    Loaded C:\temp\test\test.COD.
    BUILD SUCCEEDED: Thu Jan 26 11:13:19 2006


    Any tips?

  7. #7
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    MPASMWIN does not support the @ DEVICE config fuse directive. This is only available if you're using the PM assembler.

    If you need to place the config directive in your BASIC code, and you're using MPASMWIN, this would be the equivalent.

    @ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _BODEN_ON

    To use this in your BASIC code, you'll need to edit the 12F675.INC file in your PBP directory, and comment out the default MPASM config directive line.

    The MPASM line looks like this;

    LIST
    LIST p = 12F675, r = dec, w = -302
    INCLUDE "P12F675.INC" ; MPASM Header
    ;__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF
    NOLIST

    Use the ; symbol to comment out the default config fuse line. Save the file. Now you can add the line above directly to your BASIC code.

    Or just make the change to the 12F675.INC file & save it.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  8. #8
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    The configuration defines I gave you are valid for the default PM Assembler. If you want to use Microchips MPASM then they have to be changed to match MPASM...

    http://www.picbasic.co.uk/forum/showthread.php?t=543

  9. #9
    Qacer's Avatar
    Qacer Guest


    Did you find this post helpful? Yes | No

    Default

    Ahh, I see. I actually emailed meLabs and told them about a BUILD failed error message I got when using the PM.exe file. The guy told me to stick to MPASM if I'm not experiencing any other problem.

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


    Did you find this post helpful? Yes | No

    Default

    For what it worth, i always use MPASM. As i switch many times from 10,12,16,18 series, i don't spend time to switch between PM and MPASM. MPASM gives also some ASM advantage too.

    If you want, read the MPASM PDF to see what you can add to PBP.

    ONLY Macro is a MAIN advantage. DA,DT and other a just great too.
    Steve

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

Similar Threads

  1. ICD, ICSP and Picbasic Pro
    By mwhatley in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 8th August 2024, 20:42
  2. picbasic pro and mplab IDE
    By soelinnhtet in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 1st March 2010, 08:57
  3. How to configure SPI in PICBASIC PRO?
    By moogle in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 15th April 2007, 18:31
  4. Question for all that use MELABS PICBASIC PRO
    By oskuro in forum Off Topic
    Replies: 2
    Last Post: - 24th March 2005, 17:15
  5. PicBasic Pro & PicBasic syntax different
    By Billyc in forum General
    Replies: 5
    Last Post: - 16th April 2004, 21:19

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