Arrrr!!!! Last day after updated Eagle, I find it is now need to pay monthly…I know this six months delayed. 😅 Stupid autodesk. Thanks God, there is an opensource toolkit named KiCAD. I spend two days to study KiCAD, now EAGLE has moved into trash.
Now continue my adventure.
This time I will show you how to make spi master work.
I am trying to send some data to SPI, and data analyser read like this.
The screen protocol is like this: first bit is command/data bit, 0 means the following bits are command and 1 means the following data is parameter, from the upper picture, my send is data(1) + 0x78 + 0x56 + 0x34, totally it is 25 bits.
Send such SPI package is easy on VoCore2, you will need a directly memory writing tool, mine is mem, link here: http://vonger.cn/misc/vocore2/tools/mem.zip
First. let’s setup its speed. (PS: do not forget download the datasheet) I want to set it to 2Mbps. From datasheet, it is 193.3MHz / (rs_clk_sel + 2) = 2Mbps, we get rs_clk_sel = 94.
Now read the register 0x10000b28, get its current value. We do not need change other bits of 0x10000b28, so we must read it and put same value back to it to make sure it works normal. call “mem 0x10000b28 bit”
root@OpenWrt:/# mem 0x10000b28 bit 31:1 30:1 29:1 28:0 27:0 26:0 25:0 24:0 23:0 22:0 21:0 20:1 19:0 18:0 17:1 16:0 15:1 14:0 13:0 12:0 11:1 10:0 09:0 08:0 07:1 06:0 05:0 04:0 03:0 02:1 01:0 00:0 = 0xE02E8884
rs_clk_sel is 27:16 bits, change the 8bits from 000000010010 to 000000101110 (94 in decimal), so we should set it to 0xe02e8884, call “mem 0x10000b28 0xe02e8884” write back the register.
Rest register is similar, set 0x10000b2c(for short, I will write 0x2c) command length (cmd_bit_cnt) to 1bit, mosi bit (mosi_bit_cnt) to 24bits. 0x04 set to 1, 0x08 set to 0x12345678 (we set data length to 24bits, so spi will only send 0x345678 in 0x78, 0x56, 0x34 order).
Example: set 0x08 to 0x12345678, call “mem 0x10000b08 0x12345678”
Now, the data registers are all ready, we need to tell SPI master pump the data to physics wires. Three steps:
1. enable chip select for spi 1. (0x38 register set to 0x02)
2. start transfer. (0x00 register spi_master_start bit:8)
3. wait data transfer done. (0x00 register spi_master_busy bit:16)
4. disable chip select spi 1. (0x38 register set back to 0)
After this, you will find the same wave as my upper picture.
Looks like everything works smoothly, I should send the commands as ILI9488 datasheet described then everything should work.
But…shit always happening. I find a weird bug on ILI9488 screen 😅 have to stop there a long time and try to detours that weird bug. I will explain on my next blog.😘