Shop OBEX P1 Docs P2 Docs Learn Events
Bug Fixes to TSL230 Object in Propeller Tool Library — Parallax Forums

Bug Fixes to TSL230 Object in Propeller Tool Library

Duane DegnDuane Degn Posts: 10,588
edited 2013-06-27 10:31 in Propeller 1
I've noticed some of the older objects in the Propeller Tool library have some problems.

The most recent troublesome object I've worked with is "TSL230.spin".

While it lets one set the pins used to interface with the sensor in the Start menu (not all objects in the library as so well behaved), the TSL230 object sets the pin I/O states in such a way as to interfere with other I/O pins the cog may be using at the time.

From the "Start" method:
dira := %11 << cbase                                  'set control pins to output  
  outa := %11 << cbase                                  'set scale



The above code will set the two pins used to control the chip to outputs but at the same time it sets all the other I/O pins to inputs. So if the cog calling the Start method had also set an I/O pin to an output, the pin will be changed to an input once the TSL230 object is started.

There are of course many better ways to set pin states than the above example. This is what I used.
dira[ctrlBase + 1..ctrlBase] := %11 ' set control pins to output  
  outa[ctrlBase + 1..ctrlBase] := %11 ' set scale

(I also changed the name of the variable.)

The method "GetSample" would also change I/O states on other pins if the automatic scaling feature is enabled.

The original "Stop" method stops a different cog than started by the "Start" method. I fixed this bug and added a call to the Stop method from the Start method.

There are several objects in the Propeller Library with these type of bugs. I think these objects were written soon after the Propeller was introduced and before many of the conventions we now use had been initiated.

I know the object "ADC.spin" has several issues.

What's the best course of action to let Parallax know about these errors? Should I use the "Suggestions to Parallax" forum? Or is there someone I should email?

I think it would be nice to have an official Propeller Library that can be updated more frequently than Propeller Tool updates are released.

I've attached the modified version of the TSL230 object. This object should work with the original demo program.
Sign In or Register to comment.