28X2 portB - I need to read the current state

MrSandman

New Member
I am using Hippy's code to run a 20x2 LCD from port B on a 28x2 port B.3-B.7
I also use want to use pins B.0 and B.1. as outputs
When using the 18x I can use (using PinsB here)

Code:
symbol RS             = B.2              '0 = Command 1 = Data Register
symbol En             = B.3               '0 = Idle    1 = Enable
symbol DByte         = b1               'Data Byte for LCD
symbol RSbit	 = b2              'Data/Command Mask
symbol RSDATmask = %00000100  'Select LCD Data register
symbol RSCMDmask = %00000000 'Select LCD Command register


SendCmdByte:
   peek $30,RSbit			  'Recover OutB.0 and OutB.1
   RSbit = RSbit & %11  		  'Send to Command register
   goto SendCmdOrDataByte
SendDataByte:
   peek $30 ,RSBit		               'Recover OutB.0 and OutB.1
   RSBit = RSBit & %11 | RSDATmask	  'Send to Data register
SendCmdOrDataByte:	
   pinsB = DByte & %11110000 | RSbit   'Put MSB out first
   pulsout En,1                                   'Give a 10uS pulse on Enable
   pinsB = DByte * %00010000 | RSbit    'Put LSB out second
   pulsout En,1                   	    'Give a 10uS pulse on Enable
   return
This doesn't seem to work using port B. Writing to the LCD seems to work in the simulator but alters the state of B.0 and B.1
Is there another way of getting this to work. :confused:


Murray
 
Last edited:

inglewoodpete

Senior Member
Slow everything down while debugging

When you can't get something like a parallel LCD working, .....................slow...............it ................right.................down.

When writing to the LCD, put a 5 (or 10, 15....) second delay between the instructions - the display will wait:) Also temporarily change the PulsOuts to High/Low - Pause - Low/High for the testing.

Then, with a couple of LEDs-with-resistors (or a cheap logic probe), check the sequence of signals and that the right data is appearing on the correct lines.

Once you have it sorted, remove the delays of course.....:rolleyes:
 
Last edited:

MrSandman

New Member
Fixed and working in the sim

Hi Pete and Hippy
It was the outpinsB that had me stumpted. On the 18x I have always used the Peek $30 to get the state of the port.
On the 28X2 peek $30 command wouldn't work but outPinsB seems to work OK in the simulator (A Great bit of software is the simulator.)
The 28X2 seems to be quite differant to the 28x1 and so the data in the manual was a bit confusing. Maybe I need to look a bit harder.

Thanks Hippy and Pete for your replies and solutions.
 

hippy

Ex-Staff (retired)
The X2's are different in the way Peek and Poke work.

On non-X2, Peek and Poke will access SFR, Control Registers, Variables, Firmware Reserved Ram and User Ram, while on the X2, Peek and Poke access User Ram and Variables, PeekSfr and PokeSfr access Control Registers.
 
Top