need a little bit of help with sbic

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

I have never really had trouble using skip conditionals before but I'm really confused here..

I have PINx defined as PORTC
and PIN5 as 5.

As I understand it, it will do the debug if its clear. and Jump passed it if set.

	sbic	PINx,PIN5;( skip if 0 )
	rjmp	ready


	out DEBUG, 0
	ldi r25, 0xff
	out DEBUG, r25
ready:

Seems to be skipping in both cases?

I tried
sbic PINx,0;
and
sbic PINx,1;
just to see if it woudl work and again its getting to my debug in both cases.

The port is set to input and I use sbic later on to roll the data on to a register as a 1 or a 0. like so..

sbic	PINx,PIN5
sec
rol	r18

This works fine. But the above code always read set and never clear. Did I do something wrong?

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

Quote:

Did I do something wrong?

Read input values from PINC, not PORTC.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

theusch wrote:
Quote:

Did I do something wrong?

Read input values from PINC, not PORTC.

Actually I am, that was a type my fault.
defined as
#define PINx _SFR_IO_ADDR(PINC)

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

It should work just fine.

Run it through the Simulator.

The strange part is: 'out DEBUG, 0'

is DEBUG a special i/o register?
The 'out' instruction only takes a register.

David.

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

The code shown will work, if things are defined as you say they are. Therefore you must not be hitting that code, and ending up in your "debug" code by some other means.

Writing code is like having sex.... make one little mistake, and you're supporting it for life.

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

thx you guys, your right I was reading my analyzer wrong. and I guess
sbic PINx,0;
and
sbic PINx,1;
where not good test, or at least not working for me..

David. I know. I learned this a ways back 0 seems to null or clears it, and works out since I need my debug to be 3 clocks. Of course that only works with a 0.

Little quirks you find when you dont know what your doing, can help some times. Even though I know it should not be done that way, its a time saver in the sense of clock cycles.

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

What are you trying to accomplish?

RES

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

Using SBIS PINX,x or SBIC PINX,x says that skip next instruction if x set 1,or skip next instruction if x cleared 0.Used as a wait state entering a loop,or otherwise you must know exactly the timing of the pinx that is reading before you use it.