![]() |
Forum Index : Microcontroller and PC projects : PicoMite - thinking about PIO - and a request
![]() ![]() |
|||||
Author | Message | ||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7458 |
I think this is now assembling all 10 samples correctly except Sample 6. For <side 0> I set bit 11, and for <side 1> I set bits 11 & 12. Sample 6 doesn't seem to work the same way - I'm probably misunderstanding how the side encoding works. I think there's a variable that sets how many of the bits are used for the side encoding and I'm wondering if it has something to do with that. I'm still not happy with the parser - it's too simplistic and can't cope with multiple delimiters. It can wait though, it works well enough providing you are aware of that. I'm starting to consider how the stuff is stored in the RP2040-named registers and considering whether to use a <.state n> directive to set which state machine is being targeted. That would associate state machine variables with arrays. EDIT: Friday morning: I messed up... Just checked my prog. now. For <side 0> I set bit 12, for <side 1> I set bits 11 and 12. Bit 12 seems to be the code that this is a side command and bit 11 decides which side. In Sample 6, bit 12 isn't set by the official assembler but it is set by mine. I just need to find either my bug or why it's different for Sample 6. :) The variable I was thinking of is .side_set <count> (opt) (pindirs) (Page 338) Edit edit: If EXECCTRL_SIDE_EN is zero then every instruction performs a side set and the most significant bit of the pins allocated to side control *isn't* used to enable side set. So, if EXECTRL_SIDE_EN=0 and PINCTRL_SIDESET_COUNT=1 then <side 0> does nothing and <side 1> sets bit 12. This gives the same result as the official assembler. Edited 2021-07-02 18:14 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 4811 |
Catching up with Peter and Micks work. I am miles behind, but the playing begins... Using Micks assembler to generate hex values, and peters program command to put them in memory. This is still GP0, but I'll start playing with the other IO pins next.. From Mixtel90's PIO assembler 0 set pindirs 1 1110000010000001 E081 1 set pins,1 [9] 1110100100000001 E901 2 set pins,0 [8] 1110100000000000 E800 3 jmp 1 0000000000000001 1 4 set pins,1 [1] 1110000100000001 E101 5 set pins,0 [0] 1110000000000000 E000 6 jmp 4 0000000000000100 4 'PIO program that can output 250kHz and 50kHz on GP0 (pin 1) ' preparations SetPin 1,pio0 PIO clear 0 ' initial start and 250kHz generation PIO program line 0,0,&He081 '0: set pindirs 1 PIO program line 0,1,&He101 '1: set pins,1 [1] PIO program line 0,2,&He000 '2: set pins,0 PIO program line 0,3,1 '3: jmp 1 ' 50kHz generation (delay changed) PIO program line 0,4,&He901 '4: set pins,1 [9] PIO program line 0,5,&He800 '5: set pins,0 [8] PIO program line 0,6,4 '6: jmp 4 ' set clock 1MHz for pio0 sequencer 0 PIO init machine 0,0,1000000 ' and start the output PIO start 0,0 ' now we alternate frequencies by executing at different entries Do PIO execute 0,0,1 'entry point for 250kHz generation = line 1 Pause 1000 PIO execute 0,0,4 'entry point for 50kHz generation = line 4 Pause 1000 Loop PicomiteVGA PETSCII ROBOTS |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 4811 |
Doesn't go well. Not sure what Am I doing wrong..? I modified above program to toggle more IO pins. 'PIO program that can output 250kHz and 50kHz on GP0 (pin 1) ' preparations : reserve GP0...GP4 for PIO SetPin 1,pio0 SetPin 2,pio0 SetPin 4,pio0 SetPin 5,pio0 SetPin 6,pio0 PIO clear 0 ' initial start and 250kHz generation on 5 pins simultaneous PIO program line 0,0,&He09F '0: set pindirs &h1F PIO program line 0,1,&He11F '1: set pins,&h1F [1] PIO program line 0,2,&He000 '2: set pins,0 PIO program line 0,3,1 '3: jmp 1 ' 50kHz generation (delay changed) on 1 pin only (GP0) PIO program line 0,4,&He901 '4: set pins,1 [9] PIO program line 0,5,&He800 '5: set pins,0 [8] PIO program line 0,6,4 '6: jmp 4 ' set clock 1MHz for pio0 sequencer 0, assign 5 pins to SET group, base 0. PIO init machine 0,0,1000000,pio(pinctrl 0,5,0,0,0,0) ' and start the output PIO start 0,0 ' now we alternate frequencies by executing at different entries Do PIO execute 0,0,1 'entry point for 250kHz generation = line 1 Pause 1000 PIO execute 0,0,4 'entry point for 50kHz generation = line 4 Pause 1000 Loop I think this should work. But the set pindirs should output GP0..4, and it does not. I also tried to change the base for SET from 0 to 1 (to move the whole group of 5 IO pins to GP1...5) but that also does not seem to work. I must sure have forgotten something, but what ? PicomiteVGA PETSCII ROBOTS |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 4811 |
Maybe it is something in the pio(pinctrl x) function. If you look at the SMx_PINCTRL register in the datasheet, it has 7 variables. The pio(pinctrl x) has only 6 variables. Missing is "out_base". V. Edit: or something has gone wrong when the PIO INIT changed from: PIO INIT MACHINE pionumber, clockspeed, EXECCTRL register, SHIFTCTRL register, PINCTRL register, statemachine% to PIO INIT MACHINE pio, statemachine, clockspeed, PINCTRL register EXECCTRL register, SHIFTCTRL register Edited 2021-07-02 23:44 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 9992 |
"Documentation" bug PIO(PINCTRL no_side_set_pins [,no_set_pins] [,no_out_pins] [,IN base] [,side_set_base] [,set_base] [,out_base]) It never changed, the first version was an idea, the second was the actual implementation You code lines work when used with program execute but not in a program - I'll investigate further tomorrow. Can't see any code issue but there must be something |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 9992 |
Updated code to fix PIO on main thread More examples if useful Sample 1 0xe00f, // 0: set pins, 15 0xe08f, // 1: set pindirs, 15 0x60f0, // 2: out exec, 16 0x6030, // 3: out x, 16 0x2047, // 4: wait 0 irq, 7 0x6001, // 5: out pins, 1 0x0045, // 6: jmp x--, 5 0x60f0, // 7: out exec, 16 // .wrap_target 0x60f0, // 8: out exec, 16 0x6030, // 9: out x, 16 0xe080, // 10: set pindirs, 0 0x20a0, // 11: wait 1 pin, 0 0x2020, // 12: wait 0 pin, 0 0x2047, // 13: wait 0 irq, 7 0x4001, // 14: in pins, 1 0x004e, // 15: jmp x--, 14 // .wrap 0x4004, // 16: in pins, 4 0x0050, // 17: jmp x--, 16 0x60f0, // 18: out exec, 16 Sample 2 // .wrap_target 0xf081, // 0: set pindirs, 1 side 0 0x80a0, // 1: pull block 0xa027, // 2: mov x, osr 0x80a0, // 3: pull block 0x7001, // 4: out pins, 1 side 0 0x1844, // 5: jmp x--, 4 side 1 0xf000, // 6: set pins, 0 side 0 0x8020, // 7: push block 0x0000, // 8: jmp 0 0xf080, // 9: set pindirs, 0 side 0 0x80a0, // 10: pull block 0xa027, // 11: mov x, osr 0x5801, // 12: in pins, 1 side 1 0x104c, // 13: jmp x--, 12 side 0 0x8020, // 14: push block 0x0009, // 15: jmp 9 Sample 3 0xa242, // 0: nop [2] // .wrap_target 0x6001, // 1: out pins, 1 0xb826, // 2: mov x, isr side 1 0x0043, // 3: jmp x--, 3 0xb022, // 4: mov x, y side 0 0x0045, // 5: jmp x--, 5 0x00e0, // 6: jmp !osre, 0 0x80a0, // 7: pull block 0x60c7, // 8: out isr, 7 0x6047, // 9: out y, 7 // .wrap Sample 4 0xa242, // 0: nop [2] // .wrap_target 0x6001, // 1: out pins, 1 0x6001, // 2: out pins, 1 0x6001, // 3: out pins, 1 0xb826, // 4: mov x, isr side 1 0x0045, // 5: jmp x--, 5 0xb022, // 6: mov x, y side 0 0x0047, // 7: jmp x--, 7 0x00e0, // 8: jmp !osre, 0 0x80a0, // 9: pull block 0x60c7, // 10: out isr, 7 0x6047, // 11: out y, 7 // .wrap // .wrap Edited 2021-07-03 19:58 by matherp |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7458 |
PIO assembler wip027.zip A lot of tidying up. LOCAL info$ added so that sub could be crunched to save space. :word <word> implemented to store a 16-bit data word. Assembler now called with PASM(outarray%(),state_machine). (machines 0-3) irq instruction now works correctly (I think!) with rel option. coming: Sub initRP added to initialise the RP registers to reset values. Working on integrating the RP registers (for .wrap/.wrap target at the moment) . Edited 2021-07-04 04:06 by Mixtel90 Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 4811 |
Hi Mixtel, Please add [,out_base] to the PIO (PINCTRL commands (last option, after [,set_base]) in the documentation. Volhout Edited 2021-07-05 05:37 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7458 |
Done - it'll be in the next update. That won't be far off. :) Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7458 |
Provisional first issue of the documentation for the assembler. Please don't expect this to be much more than something to give you a feel of things. There will be changes. :) I've switched to *.rtf format for this as it's far better than *.txt for this sort of thing simply because it supports word wrap and some text attributes. I hope everyone is ok with this - I just don't like using *.doc unless I have to. lol PASM manual.zip Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
![]() ![]() |
![]() |