Moving from Basic Stamp and MIKROE basic to PicBasic PRO


Closed Thread
Results 1 to 40 of 41

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: Moving from Basic Stamp and MIKROE basic to PicBasic PRO

    Hi,
    The only config that has any actual impact on the oscillator would be the first one, the others have impact on other things but has nothing to do with the oscillator. In either case they look fine to me but if you want to set them from within your code you need get the naming correct, if you set them manually thru your programmer software it doesn't matter. If you have PBP3 I strongly suggest you open the DEVICE REFERENCE folder in the PBP3 installation directory and then open the PIC16F628.INFO (it's a plain text file). It shows you what default CONFIG PBP will use if you don't tell it otherwise and it shows you how to set whatever you want - in the code so you don't have to mess around with it in the programmer software.

    As for CMCON, open the datasheet (please use this one so we're looking at the same thing) and browse to the comparator section. Look at the description of the CMCON register and you'll see that bits 0-2 controlls the comparator mode with a note that figure 9-1 shows the various modes. Now flip the page to find figure 9-1 and find the one that suits you ie. both comparators off and you'll see that in order to do that bits 0-2 should be set - therefor CMCON = 7.

    On the 16F628 you can't really set the frequency of the internal oscillator, you can switch it between 32kHz and 4MHz (I guess that's what you meant though) and that's done by clearing (32kHz) or setting (4MHz) the OSCF bit in the PCON register. If you look at the PCON register in the datasheet you'll see that the OCSF bit is bit 3 (not bit 2 which you seem to have in your code?). So PCON.3 = 1 or if you wish you can create an alias to the bit, like:
    Code:
    OSCF VAR PCON.3
    OSCF = 1
    With that said the default state of the OSCF bit is '1' so it will start up at 4MHz.

    /Henrik.

  2. #2
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Moving from Basic Stamp and MIKROE basic to PicBasic PRO

    Ok, I've opened PIC16F628A.INFO file, and according to it:

    ; The PBP default configuration for the PIC16F628A is:
    ;
    ; #CONFIG
    ; __config _XT_OSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF

    So now, if I uncomment the line ; _FOSC_INTOSCCLK in that file, when I compile the program, the internal oscillator will be on by default?

    This everything is very confusing, look there, read this, write this, care for this, care for that. And this is called HIGH LEVEL language? Maybe such approach was fine say 30 years ago, but now? where is progress? bulk increase in MHZ and KB ?

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


    Did you find this post helpful? Yes | No

    Default Re: Moving from Basic Stamp and MIKROE basic to PicBasic PRO

    Hi,
    No, don't edit that file. If you want to change the CONFIG simply put them in YOUR program file and they will override the defaults. This is explained in the PBP3 manual and the file you just looked at.
    Code:
    #CONFIG
       __config _INTRCIO & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
    #ENDCONFIG
    Please note that I'm not sure if INTRCIO is the correct term, I don't have access to the files to check right now.

    Look, if we told you that PBP wouldn't allow you to use the internal oscillator then you'd be upset about that - why can't I do this or that, what kind of crap is this?. PBP has to use SOMETHING as default and it happens to be external x-tal for the 16F628 (and most others). Between the manual and the .info files it gives you ALL the information needed to change that and it both TELLS you and show you HOW to do it - for each and everyone of the supported devices, with comments on what every CONFIG setting does - you don't even have to open the datasheet for that.

    PBP is a high level language but it also gives you a lot of power to do exactly what you want (for example use the internal oscillator). If you don't want to mess around then stick with the defaults (ie external x-tal), include the BS2defs to get the same names for pins etc as you're used to from the BasicStamp and be done with it. I know for a fact that even with the BasicStamps you need to know which device you're using. It's the same thing here except that now you have 250 devices to choose from instead of 4 or 5.

  4. #4
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Moving from Basic Stamp and MIKROE basic to PicBasic PRO

    Thank you very much for your help.

    Can you please provide the working headers & config for pic16f628a ? because since led is not blinking, I'm not sure, whenever I'm programing it properly, or Easy PIC 7 connections/jumpers for 16f628a are correct.

  5. #5
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Moving from Basic Stamp and MIKROE basic to PicBasic PRO

    Hey CURIOUSONE, If you are expecting the compiler to know what you are thinking then GOOD LUCK... Find me one that does....If you are so courious then read the data sheet. It's not like an Android cell phone everyone has where all you do is touch the screen and all your prayers are answered with someone elses code efforts. YOU have to do some of the work by reading the documentation. I get the bigest kick out of some of the people here on the forum asking for code already written for them, instead of doing the work them selfs. There is nothing wrong with asking questions but don't dis the compiler because you don't want to do any work on your own.
    Dave Purola,
    N8NTA
    EN82fn

  6. #6
    Join Date
    Feb 2013
    Posts
    1,124


    Did you find this post helpful? Yes | No

    Default Re: Moving from Basic Stamp and MIKROE basic to PicBasic PRO

    Compiler may not known, but there are certain things, like ergonomics and usability, and this is where compiler's authors failed. In case of basic stamp, you need to press only one(!) button to let software know which chip you're using, and it will take care, not allowing you to put in the commands that aren't supported by selected chip and so on. This is so hard to implement? even for 250 chips? OK, maybe not 250 buttons, but some panel of choices, where you put checkmarks next to required clock speed, oscillator type, direction of ports and so on.

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


    Did you find this post helpful? Yes | No

    Default Re: Moving from Basic Stamp and MIKROE basic to PicBasic PRO

    I'll see if I can get a 16F628(A) with internal oscillator going tonight, provided I get the time.

    IMO, once you start locking yourself in with graphical configuration etc you loose much the flexibility.

    The compiler isn't invoked until you actually compile the program. You can write the word ADCIN in a program for a chip that doesn't have an ADC but the compiler will complain once you actually pass that program TO the compiler. It doesn't know if/what you might have done until you actually give it the file to compile.

    Like I said in the my previous post, use the defaults and you're good to go.
    The HIGH/LOW commands automatically sets the pin to output, the BUTTON, RCTIME, PULSIN etc automatically sets the pin to input. Same as on the stamps - you don't need to worry about it. The one thing you NEED to worry about is when using a pin which have an analog function - that's pretty much it.

    Why don't you need to worry about the analog input pins on the BasicStamps? That's right because they don't even HAVE an ADC or hardware comparator. If YOU choose a PIC which doesn't have ADC or hardware comparator then you don't need to worry about it either - simple as that. If YOU select a PIC with a boatload of features YOU configure them the way you want.

    It looks to me like you're doing everything you can to make it harder than it really is.

    /Henrik.

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: Moving from Basic Stamp and MIKROE basic to PicBasic PRO

    It is curious to see how one ping pongs across the different boards and how the story unfolds differently in different places.

Similar Threads

  1. Pic Basic pro code Compiling help!
    By JeromyJones in forum mel PIC BASIC
    Replies: 3
    Last Post: - 20th February 2013, 13:14
  2. Yet another SERIN2 problem - Conversion from Basic Stamp
    By Fanias in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 24th October 2012, 07:08
  3. PicBasic Pro to Basic Stamp conversion?
    By Kirk Fraser in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th March 2011, 06:49
  4. Basic Stamp BS2 replacement?
    By tenaja in forum Schematics
    Replies: 5
    Last Post: - 17th November 2009, 17:27
  5. Basic Question about PICBASIC
    By zonkwilliams in forum General
    Replies: 1
    Last Post: - 10th March 2005, 21:55

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