I am currently implementing a device which accepts 20bit of data at 2MHz.
How can i implement this?
Idealy i want a buffer accepting word´s(16bit blocks) which supplies the data to the device.
The device requires a CLOCK at 2MHz, a SYNC held high during data transfer and low for the last bit which is parity. The data goes on a third pin. The first three bits are command(and can be static 0,0,1), the following 16 bits are data and the last bit is parity (even).
I have a oscilloscope to check my progress...
I have tried the following
I set up analogWriteResolution(16);
FTM0_SYNC = 1;
FTM1_SYNC = 1;
FTM2_SYNC = 1;
attachInterrupt(digitalPinToInterrupt(pwm_pin_clock), data, CHANGE);
The interrupt executes data() once every 2-300 clock cykles so i guess this approach is to slow.
I hacked SPI.cpp / SPI.h to only send 4 bits instead of 8 so that i can have cycles of 5x4 = 20bits but my knowledge is limited and i have not managed so far
I used the IntervalTimer with hardcoded values and this was my best try so far the scope shows a clear cloch, a sync is low on every 20th bit and the data is showing nicely but...... I cant get it to go faster than 1MHz.
I have done some overclocking but it does not help in any of the scenarios i have tried so far.
Now i need assistance! Is there another approach? have i missed something or is this a hard nut to crack?