Searching \ for '[PIC]: Easier code than this?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/devices.htm?key=pic
Search entire site for: 'Easier code than this?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Easier code than this?'
2001\03\12@214703 by John Pearson

flavicon
face
I am wondering if there is a faster way to do this:


start
movlw   B'00100101'
movwf   PORTB
movlw   B'00011001'
movwf   PORTB
  .
  .
  .
  .
  .
goto start

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2001\03\12@223231 by Peter Wintulich

flavicon
face
That looks the fastest way in a PIC,

If speed is the issue and the bit pattern is not repeditive in any byte you can program a rom & loop back the data lines through a latch.
Use a pic to control the clock rate?

If the bit patten has repeditive content then use a counter chip like 74hc4040, this 11 bit bin counter has a reset & clock inputs.

another way could be a lookup table, but that is much slower. but would allow multitasking.
--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2001\03\13@074736 by mike

flavicon
face
On Tue, 13 Mar 2001 06:40:11 -0800, you wrote:

>I am wondering if there is a faster way to do this:
>
>
>start
>movlw   B'00100101'
>movwf   PORTB
>movlw   B'00011001'
>movwf   PORTB
>   .
>   .
>   .
>   .
>   .
>goto start

depends what you mean by faster. if you mean higher frequency pulses,
you could do :
movlw   B'00100101'
movwf   PORTB
movlw B '00111100'

loop
 xorwf PORTB
goto loop

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\03\13@081941 by Drew Vassallo

picon face
>movlw   B'00100101'
>movwf   PORTB
>movlw   B'00011001'
>movwf   PORTB

Depends on what you're trying to load into PORTB.  If they're all just
independent values, then no, there's no faster way.  If they're some sort of
sequential values, then you can certainly put them into a loop.

If you're going to modify the PORTB latches directly, it might be best to
adjust a "temporary register" first, then write it all to PORTB at the end.
But then again, I have no idea what your application is, so this may not
work.

--Andrew
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\03\13@091239 by Scott Dattalo

face
flavicon
face
On Tue, 13 Mar 2001, Mike Harrison wrote:

{Quote hidden}

 I didn't see the beginning of this thread, so I may've missed something..

at the risk of generating false outputs, you could do this:

  movlw   '00100101
  movwf   PORTB
  movlw   '00100101' ^ '00011001'

start
  xorwf   PORTB
  xorwf   PORTB
  xorwf   PORTB
  xorwf   PORTB
  xorwf   PORTB
  xorwf   PORTB
  xorwf   PORTB
...

eventually the goto at the end will cause a 2-cycle delay

Or you can compress the code as Mike shows:
>
> loop
>   xorwf PORTB
>  goto loop


Now, you do have to be careful with this approach because the read-modify-write
operations applied to an I/O port (on a PIC) may not work the way you
expect. Specifically, just because you write a value to an I/O pin it doesn't
mean that I/O pin assumes that value. There could be a large capacitive load for
example that could hold the I/O line in it's previous state for several
instruction cycles. So for example if you tried to write 0 1 0 1 it could come
out as 0 1 1 0 (because the 2nd write [of a 1] didn't fully drive the I/O high,
consequently the 3rd RMW reads a 0 toggles it and writes a 1...)

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\03\13@133816 by Bill Westfield

face picon face
>movlw   B'00100101'
>movwf   PORTB
>movlw   B'00011001'
>movwf   PORTB

There are DENSER (and perhaps prettier) ways, involving table reads from
code space or EEPROM:

loop:   call getval
       movwf PORTB
       jump loop

Where getval looks an awful lot like the 2-wire LCD code we've been talking
about recently...

BillW

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...