about pic and picbasic

Discussion in 'Embedded Systems and Microcontrollers' started by electronic_noob, Jan 29, 2010.

  1. electronic_noob

    Thread Starter Member

    Jan 15, 2010
    42
    1
    hello, there are some questions about pic and picbasic that i is in my mind
    im making a project and Im finding it hard to find the answers on my own, so guys I desperately need your help

    Im using PIC16F628A
    with PICBASICPRO compiler

    questions:

    1. Is there a default state on the port pins of the pic, like the RBports 2-6 which I think has a default state of LOW, and the RBport 0-3 and 7 which have a default state of high and am i right or should I take a look on my program again

    2.how can I extract the the binary bits, let me redefine it by example
    I have 4 LEDS which I need to turn 'ON' by a pc's serial port. The combinations of the leds being turned on is dependent on the data that would be send by the serial port of the pc. My idea is since there are 4 leds i figure out maybe i could assign each led on each bit of the last four bit of the data.
    for example:
    0000/0001
    the last 4bit is 0001=> 0 0 0 1
    LED1 LED2 LED3 LED4
    so instead of the input of too many codes, i figure out setting like that, on that way i could lessen up the code by using loops and arrays

    can I extract each bit?


    thanks in advance
     
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    Google the term ->PICBASIC PRO Bitwise Operators
    It will help you out:)
     
  3. Art

    Distinguished Member

    Sep 10, 2007
    785
    61
    Yes, say the four LEDs are connected to the first four portb pins (0-3).

    Take the byte you are trying to get the last four bits from
    Code ( (Unknown Language)):
    1.  
    2. databyte var byte
    3.  
    Set the lower end of portb to the first four bits of the data byte:

    Code ( (Unknown Language)):
    1.  
    2. portb.0 = databyte.bit0
    3. portb.1 = databyte.bit1
    4. portb.2 = databyte.bit2
    5. portb.3 = databyte.bit3
    6.  
    Cheers, Art.
     
  4. Art

    Distinguished Member

    Sep 10, 2007
    785
    61
    Oops.... Yeah, What Alberto said as well :)
     
  5. electronic_noob

    Thread Starter Member

    Jan 15, 2010
    42
    1
    and one other thing in using EEPROM, in PICBASICPRO it s as simple as
    write 1,b0
    and
    read 1,b1

    the one thing that i want to ask is there anything i need to include at the header of my source code, like those DEFINE commands...

    and is there anything i must do in the PIC component is there some connection I need to do to in order to enable the EEPROM my PIC is 16f628A


    [​IMG]
    [​IMG]and one last thing i get this error, and I really dont know what to do because im so unfamiliar with the error, Im using proteus and i get this error
    'STACK UNDERFLOW EXECUTING RETURN INSTRUCTION
    'STACK OVERFLOW EXECUTING CALL INSTRUCTION

    i understand that the RETURN instruction is use for returning to the main program after a subroutine and the call instruction is related to the definition of the assembly language being included

    but I did not use any assembly language in my source code, and I have excluded all subroutines and revise my code but Im still getting that error

    please help me:
     
Loading...