Don,
is it recommended now to change existing putpin/getpin calls to the appropriate new calls where the pin is know at compile time ?
Is the code overhead reduction significant ?
Are there any downsides known at the moment ?
thanks
New compiler
Re: New compiler
Unless you just want to try them, I would recommend leaving existing applications as they are. The primary advantage to using the new functions is that they have a very low and constant overhead, allowing very fast pin manipulation. This is accomplished by having the compiler emit code to directly read and/or write the I/O port containing the pin - that's why the pin must be known at compile-time.FFMan wrote:is it recommended now to change existing putpin/getpin calls to the appropriate new calls where the pin is know at compile time ?
As an example of the speed difference, consider the program below that can be compiled to use either PinOutput() or PutPin() in a loop to toggle an output pin. With PinOutput() the loop cycle time on a ZX-24n is 890nS and with PutPin() it is 10uS. Note, however, that the code size for the application compiled the two ways happens to be the same. This won't always be the case but it is unlikely that the code size would ever be larger when using the direct pin functions.
Code: Select all
Const pin as Byte = 13
' uncomment the next line to use direct pin functions
#define USE_PIN_FUNC
Sub Main()
Dim b as Byte
b = 0
Call PutPin(pin, b)
Do
b = b Xor 1
#if defined(USE_PIN_FUNC)
Call PinOutput(pin, b)
#else
Call PutPin(pin, b)
#endif
Loop
End Sub
- Don Kinzer