Thanks Thorsten
I’ve checked out the new fast scan program with MIOS Studio and the results are attached. The pin Nos are shown in Red. I’ve also checked out reducing the number of rows to 13 rather than 16. It works fine, as would be expected.
In addition I’ve marked in Green the Note Nos. You will see that when the first key A0 is pressed that pin 1 closes followed by pin 2.
The sequence of what happens is shown with an extract from MIOS Studio.
When the key A0 is pressed the 1st switch of the A0 key closes (row 1,col 0, pin value = 0),the 2nd switch closes (row 2, col 0, Pin value = 0).
When the key is released the 2nd switch returns to a pin value 1, followed by the 2nd returning to pin value 1
[3603.390] [bUTTON_NotifyToggle] row=0x01, column=0x00, pin_value=0
[3603.390] [bUTTON_NotifyToggle] row=0x02, column=0x00, pin_value=0
[3603.500] [bUTTON_NotifyToggle] row=0x02, column=0x00, pin_value=1
[3603.515] [bUTTON_NotifyToggle] row=0x01, column=0x00, pin_value=1
Instead we use our own scan routine now,
In order to keep it simple, we use MIOS32_SPI_TransferByte() accesses directly without DMA and without callbacks.
It’s fast enough for your usecase.
The TASK_MatrixScan() task handles the transfers and calls BUTTON_NotifyToggle() whenever a change on the DIN pins has been determined.
This task performs the scan each mS - which means in other words, that the worst-case latency is 1 mS which should be acceptable.
My scope tells me, that the 16x16 scan takes 400 uS (*), which means that the core is loaded by ca. 40% and could do (many) other things in parallel…
(*) speed could be significantly improved by selecting a faster SPI clockrate, but for your usecase the current speed setting is acceptable (and it leads to more robust results!)
The exercise has shown the order in which the keyboard switches are scanned and is very useful. It has also helped me to better understand the programming methodology.
For the final version, which will be velocity sensitive, I have always thought that the scan time should as small as possible and that DMA transfer would be needed to achieve this. I understand with the default settings and using DMA a 16 X 16 matrix can have a 220 microsecond scan time. From your scope measurements 400 microS is about twice this.
Duggle discussed this in an earlier message to me. For a very soft key press 128 scans may be needed (if max resolution were to be achieved!). This would take 128 mS at 1mS per scan. Maybe this is too long?
So far, with the 16 X16 matrix I have not seen any evidence of switch bounce using MIOS Studio.
Another thought I have is to investigate “impedance matching” between the DOUT outputs and the DIN Inputs. Has any work been done on this?
This might help in allowing higher frequency clocks. Perhaps some of Duggle’ recent work on chaining shift registers may give some pointers.
Thanks Again
Robin
PS Towards the end of Fast scan 16 X 16 there is a STATUS line. What is this for?
// read DIN, write DOUT
s32 status = 0;
u8 din0 = MIOS32_SPI_TransferByte(MIOS32_SRIO_SPI, (select_row_pattern >> 8) & 0xff);
u8 din1 = MIOS32_SPI_TransferByte(MIOS32_SRIO_SPI, (select_row_pattern >> 0) & 0xff);
[Row Col Fast Scan A.doc](< base_url >/applications/core/interface/file/attachment.php?id=7838)