Started using PICBasic Pro 2.46


Closed Thread
Results 1 to 10 of 10

Hybrid View

  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?

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