Back to the ZX24 laptimer project.
I used the 8 bit LCD example code from this site and created a small test program that proves my LCD connections work. I had to move the use of port c to port a to free pin 12 for later use. I also created a couple of wrapper functions so that the provided code emulated my previous I2c driven LCD version - so far so good.
I then took the decde the IR signal example code and used this to create another small test program to decode my IR beacon signal, with useful help from the forum this is also working well.
I then incorporated these two modules into a copy of BX24 laptimer project and made the necessary changes so that the IR decode was a separate task.
This where things started to go wrong - If I comment out the InputCapture statement, everythings works as expected, and by that i mean all the code to set the clock, store and retrieve the laptimes, and using the timer in test mode (using a button to emulate the beacon) work as expected.
When I uncomment the inputcapture and run the project for real, the program fails to ouptut anything anythng to LCD display after the initial display. Through the use of debug statements i can see the code is executing and as I would expect its just the LCD display never changes. The code to put the pins high/low is executing but the display never changes.
is this a timing issue do you think ? should i lock the lcd task at the point it writes ?
any help much appreciated
thanks
Odd program behaviour
a bit more investigation reveals that if i change
Pulseout(lcd_pin,2,1) to
call PutPin(LCD_Enable,zxOutputHigh)
call delay (0.002)
call PutPin(LCD_Enable,zxOutputLow)
it works.
I wondered if this is a timer issue, but the documentation states timer1 is used for inputcapture and timer2 for pulseout but clearly there is some interaction at work.
Pulseout(lcd_pin,2,1) to
call PutPin(LCD_Enable,zxOutputHigh)
call delay (0.002)
call PutPin(LCD_Enable,zxOutputLow)
it works.
I wondered if this is a timer issue, but the documentation states timer1 is used for inputcapture and timer2 for pulseout but clearly there is some interaction at work.
I suspected that you were using some of the time-based I/O routines. Since InputCapture() typically uses the I/O Timer and the time-based I/O routines do, too there is a resource conflict.FFMan wrote:I wondered if this is a timer issue, but the documentation states timer1 is used for inputcapture and timer2 for pulseout.
Where did you see a reference to Timer2 being used for PulseOut()? The latest documentation (on the website) indicates that the I/O Timer is used. The I/O Timer is always a 16-bit timer and on most ZX devices it is Timer1. Most ZX devices have only one 16-bit timer; some of the larger ones, e.g. ZX-1280, have multiple 16-bit timers. Timers 0 and 2 are 8-bit timers. Refer to the table Timer Usage by CPU Type for more details.
The Delay() call implements its timing based on the RTC timer.
- Don Kinzer
Don,
the reference to timer2 was in the table you kindly put a link in your previous response in the IR decode thread previous to this.
The zbasic system library manual i have states iotimer is used on pulseout, but doesn't explicity state iotimer is used on inputcapture.
As this is all quite new to me, I guess I still have some to learn. For now though it is fixed and almost ready for trial at the circuit next month.
thanks - the excellent responses on this forum are part of what makes the zx such a good product to work with. Expect some more questions when I try and port this to a native mode device !
the reference to timer2 was in the table you kindly put a link in your previous response in the IR decode thread previous to this.
The zbasic system library manual i have states iotimer is used on pulseout, but doesn't explicity state iotimer is used on inputcapture.
As this is all quite new to me, I guess I still have some to learn. For now though it is fixed and almost ready for trial at the circuit next month.
thanks - the excellent responses on this forum are part of what makes the zx such a good product to work with. Expect some more questions when I try and port this to a native mode device !
Note that Register.TimerSpeed1 and Register.TimerSpeed2 are prescaler values used for the I/O timer. TimerSpeed2 has nothing to do with Timer2 but I can see the possible confusion.FFMan wrote:the reference to timer2 was in the table you kindly put a link in your previous response in the IR decode thread previous to this.
Perhaps it isn't explicit enough. The table Valid Input Capture Pins does show which 16-bit timer is used for InputCaptureEx() on specified pins. Note that InputCapture() is like InputCaptureEx() with the pin specified corresponding to the I/O timer (again, typically Timer1).FFMan wrote:The zbasic system library manual i have states iotimer is used on pulseout, but doesn't explicity state iotimer is used on inputcapture.
- Don Kinzer