Sign in

username:

password:



Not a member?

Search basicx



Search tips

Subscribe to basicx



basicx by Keywords

Accelerometer | ADC | ADXL | Adxl20 | AVR | BasicStamp | BX-35 | BX28 | BX35 | COM3 | Compiler | Downloader | EEPROM | Electromagnet | GetADC | GP2D1 | GPS | I2C | IDE | Keypad | LCD | LCD+ | MIDI | Motors | Multitasking | Netmedia | Networking | PCB | PID | PlaySound | PWM | Relays | RTC | Servo | ShiftOut | SitePlayer | SPI | Stack | Timer | USB

Ads

Discussion Groups

Discussion Groups | BasicX | 1st of 2 questions: Reading parallel bits

Discussion forum for the BasicX family of microcontroller chips.

1st of 2 questions: Reading parallel bits - bobbymcgill2007 - Jan 17 10:48:20 2008

Hi all - I have 2 questions that I am separating into different posts to
hopefully avoid any confusion.

First:
I have a circuit that reads in 8 bits of serial data, then shifts them
over to an 8 pin register that can be read in parallel. I would like to
read in the data and send each byte read out the com1 port.
Here is how I am currently doing it:

call openqueue(outputQ, 10) 'Only transferring 1 byte at a time
call openqueue(inputQ, 10) 'Only used because there needs to be 2
queues. It is ignored
call opencom(1, 19200, inputQ, outputQ) ' inputQ will be ignored
dim x as byte

do
call waitforinterrupt(bxpinrisingedge)

call putbit(x, 0, getpin(13))
call putbit(x, 1, getpin(14))
call putbit(x, 2, getpin(15))
call putbit(x, 3, getpin(16))
call putbit(x, 4, getpin(17))
call putbit(x, 5, getpin(18))
call putbit(x, 6, getpin(19))
call putbit(x, 7, getpin(20))

call putqueue(outputq, x, 1)
loop

I know I could use a loop to read this instead of 8 separate line. But
- isn't there a better way? This way works, but I feel it is VERY
amateurish. Is there some command that would grab all 8 pins as a byte?
Even better - could all 8 pins be grabbed and then sent out the com
port?

Feel free to critique my code - because I honestly am quite new to this.

[Non-text portions of this message have been removed]



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )


Re: 1st of 2 questions: Reading parallel bits - Tom Becker - Jan 17 12:13:50 2008


> call putbit(x, 0, getpin(13))
> call putbit(x, 1, getpin(14))
> call putbit(x, 2, getpin(15))
> call putbit(x, 3, getpin(16))
> call putbit(x, 4, getpin(17))
> call putbit(x, 5, getpin(18))
> call putbit(x, 6, getpin(19))
> call putbit(x, 7, getpin(20))
>
Those eight instructions can be replaced with
x = Register.PinA
which reads the eight pins simultaneously, except that the LSB is on pin 20.
Tom



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )

Re: 1st of 2 questions: Reading parallel bits - bobbymcgill2007 - Jan 17 15:02:33 2008

--- In b...@yahoogroups.com, Tom Becker wrote:
> > call putbit(x, 0, getpin(13))
> > call putbit(x, 1, getpin(14))
> > call putbit(x, 2, getpin(15))
> > call putbit(x, 3, getpin(16))
> > call putbit(x, 4, getpin(17))
> > call putbit(x, 5, getpin(18))
> > call putbit(x, 6, getpin(19))
> > call putbit(x, 7, getpin(20))
> >
> Those eight instructions can be replaced with
> x = Register.PinA
> which reads the eight pins simultaneously, except that the LSB is on
pin 20.
> Tom
>

Brilliant! Thanks! It worked like a champ, and gave me a 300% boost in
processing ability. (ie - I boosted my serial data rate input from 12k
to 39k)



(You need to be a member of basicx -- send a blank email to basicx-subscribe@yahoogroups.com )