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,624


    Did you find this post helpful? Yes | No

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

    Hi,
    That's a good start. Couple of notes:
    DEFINE OSC 4 does not SET the oscillator to 4Mhz it simply tells the compiler at what speed you INTEND to run the chip so it (the compiler) can calculate delay loops etc.
    CMCON = 0 does not turn off the comparator, look at the datasheet.

    /Henrik.

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


    Did you find this post helpful? Yes | No

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

    OK, understood. Going further. By googling I figured out that for my needs (using int. osc), I need to set fuses as follows:

    Oscillator: IRCIO
    WDT=OFF
    LVP=OFF
    MCLRE=OFF
    PWRTE=ON

    regarding the CMCON, by googling I found it to be set to 0x07, to disable comparators. However, I was not able to find that information in datasheet (I'm sure it is in there, just I'm looking in the wrong way).

    Also, how should I set clock frequency? OSCF=%0000100 ?

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


    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.

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


    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 ?

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


    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.

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


    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.

  7. #7
    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

  8. #8
    Join Date
    Feb 2013
    Posts
    1,157


    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.

Similar Threads

  1. Pic Basic pro code Compiling help!
    By JeromyJones in forum mel PIC BASIC
    Replies: 3
    Last Post: - 20th February 2013, 14: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, 08:08
  3. PicBasic Pro to Basic Stamp conversion?
    By Kirk Fraser in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th March 2011, 07:49
  4. Basic Stamp BS2 replacement?
    By tenaja in forum Schematics
    Replies: 5
    Last Post: - 17th November 2009, 18:27
  5. Basic Question about PICBASIC
    By zonkwilliams in forum General
    Replies: 1
    Last Post: - 10th March 2005, 22: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