40x2 portB direction problem

BillyGreen1973

Senior Member
I'm just starting to design a 32 LED controller for an arcade machine project.
The 40x2 recieves data from the PC using 'serrxd' in the form of

identifer,byte1,byte2,byte3,byte4

It then simply loads the output ports with these bytes, thus controlling 32 leds.

The problem I'm having is this, when I simulate the code below, B.0 returns to an input after the serial data is recieved, even though it is set to an output in the 'init' section.
If I move the 'Let dirsB=255' line to after the Serrxd, all is fine.
I would prefer to keep the 'Let DirsB' command in the init section, just for neatness (it also may be a little quicker?), but what am I doing wrong?
I don't know if it is a code issue, or sim issue. (I dont have a 40x2 to try it on yet)

Thanks

Code:
init:

#picaxe 40x2

   let dirsA=255	;set all ports to outputs
   let dirsB=255
   let dirsC=255
   let dirsD=255
   
main:
;requires 254 as identifer, receive 4 bytes into b0 to b3
   
	serrxd (254),b0,b1,b2,b3

;load outputs with b0 to b3	
   outpinsA=b0
   outpinsB=b1
   outpinsC=b2
   outpinsD=b3
goto main
 

hippy

Ex-Staff (retired)
Thanks for the report which we will investigate. It is likely just a simulation issue.
 
Top