Updating PNS LCD problems

nrking

New Member
Hi, I've followed the example code in the NET manual to try and update both lines on the PNS LCD from code in a PICAXE 28X as shown below, but it only updates the bottom line on the LCD:

writei2c 22, ( %00001111 )
writei2c 40, (" Auto Switching ")
writei2c 22, ( %10001111 )
writei2c 40, (" Test Box 001 ")

To get it to work I have to use a selectcase statement within the routine and gosub to it twice ie

select case MessageFlag
case 0 'Welcome message
writei2c 22, ( %00001111 )
writei2c 40, (" Auto Switching ")
case 1
writei2c 22, ( %10001111 )
writei2c 40, (" Test Box 001 ")
end select

This surely cannot be correct so any help will be appreciated.

Also is there a way of storing predefined messages for the LCD?

Thanks
 

Technical

Technical Support
Staff member
The first code does not work as you must let the PNS regain control of the i2c bus between the LCD writes i.e. the byte 22 'copy to LCD' instruction can only be executed when the PNS regains control of the i2c bus. At the moment your first program code does not allow the PNS to use the i2c bus between the two byte 22 instructions, so the first one is ignored.

This is also why your second program works, as (by default) using the gosub twice you are releasing the i2c bus between each set.
 
Top