status input pin shift in to a byte

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hallo,

i think it is not a big problem, but i just don't see how to fix it.

 

i have 2 pins: 1 input and 1 output:

pinc3 = input serieel data comes in (90000 bits)

pinc4 = output clock pulse to synchronize 

 

the speed is very slow something like 375 bytes/sec.

when 8 bits are in (a byte) i write it away in a externe RAM.

 

i like to do this with the shift instructions, so on the moment the clock = 1, i ask the status of pc3 (serieel in) and the result

i wanna gonna shit in to a byte.

but can i directly shift the status of a input pin in a byte, ore do i need a conversion ?

 

thanks in advance.

 

 

 

Last Edited: Tue. Aug 6, 2019 - 09:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

C or assembler?

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

byte<<=1;
If (pin)
{
byte|=1;
}

Do you want most significant bit first or leadt significant bit first?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman wrote:
Do you want most significant bit first or leadt significant bit first?
The alternative being:

 

byte>>=1;
If (pin)
{
byte|=0x80;
}

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

its in C

 

if i'am correct:

byte<<=1  is the same as  byte=byte<<1

and

byte|=1  is the same as  byte=byte|1

 

so:

byte=byte<<1     // here the byte is shift 1 pos. to the left

if(pin)                 // here i gonna ask if the serieel pin = "1"

{

byte=byte|1       // if serieel pin = "1"  the "1" is gonna place at the LSB

}

 

but wat i have to do when the serieel input pin = "0" ?

Last Edited: Wed. Aug 7, 2019 - 05:55 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

trixo wrote:

its in C

 

if i'am correct:

byte<<=1  is the same as  byte=byte<<1

and

byte|=1  is the same as  byte=byte|1

 

so:

byte=byte<<1     // here the byte is shift 1 pos. to the left

if(pin)                 // here i gonna ask if the serieel pin = "1"

{

byte=byte|1       // if serieel pin = "1"  the "1" is gonna place at the LSB

}

 

but wat i have to do when the serieel input pin = "0" ?

the first shift above (byte = byte<<1;) shifts in a zero so nothing else needs to happen, but...

if the pin ==1, then the (byte = byte|1;) changes the zero to a one!

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
stack gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok, now i see it,....thanks for the answer.