about pic and picbasic

Thread Starter

electronic_noob

Joined Jan 15, 2010
42
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
 

Art

Joined Sep 10, 2007
806
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
Rich (BB code):
databyte var byte
Set the lower end of portb to the first four bits of the data byte:

Rich (BB code):
portb.0 = databyte.bit0
portb.1 = databyte.bit1
portb.2 = databyte.bit2
portb.3 = databyte.bit3
Cheers, Art.
 

Thread Starter

electronic_noob

Joined Jan 15, 2010
42
.... And remember to set the port pins as output using the trisB register.

TRISB = %11110000 ' bits 0-3 = outputs bits 4 -7 = inputs

or

TRISB = %00000000 ' all port B pins as output

Alberto
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



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:
 

Attachments

Top