{ Micropython with VGA text output (PST format) Version 1.3 - 10th January 2020 - ozpropdev Mu editor raw mode compatible Smartpin I/O Pin #2 <-------------- #63 #1 <-------\ | | #0 -----\ | | | #63 <----/ | | #62 --------o-----> #62 } con xtal = 20_000_000 dv = 20 mlt = 252 '252 Mhz sys_clk = xtal / dv * mlt clk = 1 << 24 | (dv-1) << 18 | (mlt-1) << 8 video_basepin = 48 pst = video_basepin + 4 video_buffer = $7_c000 baudrate = 115_200 nco = (sys_clk / baudrate) << 16 ' pst_cog = 7 up_cog = 6 fake_rx = 0 micropython_out = 1 new_rx = 2 rx_buffer = $7_8000 dat org 'configure clock hubset ##clk | %1111_01_00 waitx ##20_000_000/100 hubset ##clk | %1111_01_11 'load pst video driver loc ptra,#@video setq ##video_buffer << 8 | video_basepin coginit #pst_cog,ptra 'move micropython image to hub address 0 mov ptra,##$400 mov ptrb,#0 rep @loop,##(@up_end - @up) rdbyte pa,ptra++ wrbyte pa,ptrb++ loop 'setup async receiver to monitor outgoing text from micropython wrpin ##%0101_0000_000_00000_00000000_00_11111_0,#micropython_out wxpin ##nco | 7,#micropython_out dirh #micropython_out 'setup fake rx (feeds pin 63) wrpin #%01_11110_0,#fake_rx wxpin ##nco | 7,#fake_rx dirh #fake_rx 'setup new rx (snoop pin 63) wrpin ##%0101_0000_000_0000000000000_0011111_0,#new_rx wxpin ##nco | 7,#new_rx dirh #new_rx 'start pst driver cogatn # decod pst_cog 'start micropython coginit #up_cog,#0 'redirect micropython receiver to snoop pin #0 waitx ##sys_clk / 10 wrpin ##%0001_0000_000_0000000000000_00_11111_0,#63 'setup rx interrupt setse1 #%001_000000 | new_rx 'rising edge mov ijmp1,#rx_isr setint1 #4 ' **** MAIN loop ****** main cmp head,tail wz if_e jmp #main2 mov fx,##rx_buffer add fx,tail rdbyte pa,fx incmod tail,##(15*1024)-1 wypin pa,#fake_rx getct ax addct1 ax,##(sys_clk / 1000000)* 400 xxx pollct1 wc if_nc jmp #xxx 'send out going text to vga driver too. main2 testp #micropython_out wc if_nc jmp #main rdpin pa,#micropython_out shr pa,#24 'send to pst driver via repository (cideo_basepin + 4 = vsync) send testp #pst wc if_c jmp #send wxpin pa,#pst jmp #main 'interrupt service routine for rx rx_isr rdpin char,#new_rx shr char,#24 mov fx,##rx_buffer add fx,head wrbyte char,fx incmod head,##(16 * 1024)-1 reti1 ax long 0 char long 0 fx long 0 head long 0 tail long 0 '=========================================================== orgh $400 up file "P2_Native_MicroPython_1JAN2020.bix" up_end video file "pst_15_revb_02.obj"