LCDInfo.com

http://www.lcdinfo.com
It is currently Thu Nov 21, 2024 23:52

All times are UTC + 2 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Mar 29, 2006 21:08 
Offline

Joined: Wed Aug 03, 2005 20:27
Posts: 130
Location: .fi
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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 30, 2006 14:04 
Offline

Joined: Sun Feb 26, 2006 14:56
Posts: 6
Location: Australia
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.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 12, 2006 0:53 
Offline

Joined: Tue May 09, 2006 23:39
Posts: 6
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 2 hours


Who is online

Users browsing this forum: No registered users and 49 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group