DEMO RGB VIDEO PLAY 16b SPI1- SPI2
|
Device = 33EP128MC504 Declare Xtal = 150 Declare Watchdog = OFF Declare Warnings = OFF Declare Stack_Expand = On Declare Optimiser_Level = 3 Declare Access_Upper_64K = On '================ TFT SCREEN ================ $define TFT_IC ST7789V $define TFT_COM SPI_2 $define TftScreenWidth 320 $define TftScreenHeight 240 $define TFT_CS PORTC.9 $define TFT_RESET PORTC.2 $define TFT_DC PORTC.1 $define TFT_MOSI PORTC.6 $define TFT_MISO PORTC.5 $define TFT_SCLK PORTC.7 $define _TFT_MOSI _PORTC.6 $define _TFT_MISO _PORTC.5 $define _TFT_SCLK _PORTC.7 '================ TFT TOUCH ================ $define TOUCH_IC XPT2046 $define TOUCH_COM SPI_SW $define Z_Threshold 800 $define TouchAveragePoints 2 $define TouchMedianDistance 8 $define T_CS PORTC.8 $define T_IRQ PORTA.8 $define T_MOSI PORTC.6 $define T_MISO PORTC.5 $define T_SCLK PORTC.7 $define _T_MOSI _PORTC.6 $define _T_MISO _PORTC.5 $define _T_SCLK _PORTC.7 '================ MCU ================ $define McuType 1 '================ SD CARD ================ $define SDCardUsed 1 $define SDCardFatUsed 0 $define SD_COM SPI_1 $define SD_CS PORTA.1 $define SD_SDO PORTA.4 $define SD_SDI PORTA.9 $define SD_CLK PORTC.3 $define _SD_SDO _PORTA.4 $define _SD_SDI _PORTA.9 $define _SD_CLK _PORTC.3 '================ MEMORY ================ $define MemoryType 2 $define MEM_COM SPI_1 $define MEM_CS PORTA.7 $define MEM_MOSI PORTA.4 $define MEM_MISO PORTA.9 $define MEM_SCLK PORTC.3 $define _MEM_MOSI _PORTA.4 $define _MEM_MISO _PORTA.9 $define _MEM_SCLK _PORTC.3 $define MEM_PAGE_SIZE 256 $define MEM_SECTOR_SIZE 4096 $define MEM_SECTOR_COUNT 2048 $define MEM_FILE_COUNT 256 $define MEM_WRITE_DELAY 5 '================ FONT ================ $define FontSmooth 0 $define FontMaxSpace 8 $define FontMaxPixels 8 Include "TftLib\Fonts\BDF\F5_BDF_Sail-Regular-25.inc" Include "TftLib\TFT_Graphic_Lib.inc" $define Seafarer 300,220,8,782468 '0,300,220,8,782468,CGI Animated Short Film _Sticking Seafarer_ by Jeremy Ross _ @CGMeetup.mp4 $define Bird 782469 '1,320,240,782469,782769,Bird.jpg $define Countdown 300,220,782770,883574 '2,300,220,782770,883574,Old Film Countdown.mp4 Main: Clear SetCrystal() SetPins() TftBmpMemSet() DelayMS 2000 TftSetUp(0) TftResetScreen(APRICOT) TftSetBdfFont(5) TftPrintBdfString("Positron video from RAW", 14,200,479,1,BLACK,BLACK,1) DelayMS 2000 TftRgbFromSdRaw(10,10,Countdown,0) TftBmpFromSdRaw(0,0,Bird) TftPrintBdfString("Positron video from RAW", 14,200,479,1,RED,BLACK,1) DelayMS 2000 TftRgbFromSdRaw(10,10,Seafarer,0) End 'Set Fosc Proc SetCrystal() 'Crystal = 16 MHz --> PLLDIV = 68 for 140MHz / PLLDIV = 73 For 150MHz CLKDIV = %0000000000000010 'PLLPRE = 2 ; PLLPOST = 0 PLLFBD.Byte0 = 73 '--> 150MHz Fp 'Wait for oscillator PLL lock While OSCCON.5 = 0 : Wend DelayMS 100 EndProc Proc SetPins() 'Set all digital ANSELA = 0 ANSELB = 0 ANSELC = 0
'RP55 to SCK2 / RP54 To SDO2 / RPI53 to SDI2 RPOR5.Byte1 = %00001001 'RP55 RPOR5.Byte0 = %00001000 'RP54 RPINR22.Byte0 = %00110101 'SDI2 RPINR22.Byte1 = %00110111 'SCK2 SPI2CON1 = 0x033B '8b / SPRE[2:0] 2:1 / PPRE[1:0] 1:1 SPI2STAT = 0x8000
SPI1CON1 = 0x033B '8b / SPRE[2:0] 2:1 / PPRE[1:0] 1:1 SPI1STAT = 0x8000 EndProc Config FICD = ICS_PGD1, JTAGEN_OFF Config FPOR = ALTI2C1_OFF, ALTI2C2_OFF, WDTWIN_WIN25 Config FWDT = FWDTEN_OFF, PLLKEN_ON, WDTPOST_PS16384, WDTPRE_PR128, WINDIS_OFF Config FOSC = FCKSM_CSECMD, IOL1WAY_OFF, OSCIOFNC_OFF, POSCMD_HS Config FOSCSEL = FNOSC_PRIPLL, IESO_ON, PWMLOCK_OFF Config FGS = GCP_OFF, GWRP_OFF |
Created with the Personal Edition of HelpNDoc: Full-featured Kindle eBooks generator