LCDInfo.com
http://forum.lcdinfo.com/

Another SPI-related question
http://forum.lcdinfo.com/viewtopic.php?f=9&t=1524
Page 1 of 1

Author:  Zee [ Wed Mar 29, 2006 21:08 ]
Post subject:  Another SPI-related question

I'm trying to control SPI-type display with PIC and I have this problem sending the needed 9 bits (data is in bit 0, clock in bit 1):

Works:
Code:
      ...
      ANDLW   H'01'
      MOVWF   PORTB
      MOVLW   H'02'
      MOVWF   PORTB
      ...


Doesn't work:
Code:
      ...
      ANDLW   H'01'
      MOVWF   PORTB
      BSF   PORTB,1
      ...


I just can't figure out why the shorter version doesn't work. Both look fine in the simulator.

Author:  Kartman [ Thu Mar 30, 2006 14:04 ]
Post subject: 

I seem to recall some limitation with the PIC in that you have to wait a machine cycle between each port write - that's probably why the shorter code doesn't work.

Author:  MrPhelps [ Fri May 12, 2006 0:53 ]
Post subject: 

This may be a read-modify-write issue. It's mentioned in the datasheet in the ports description section.

The BSF works that way : it reads the value, modifies it, and then writes it back. The problem is that depending on the impedance of the circuit connected to the output, the value read is not necessarily what was written before. So this instruction may modify more than one bit.

Page 1 of 1 All times are UTC + 2 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/