Absolute Prop NEWB, trying to simultaneously toggle GPIO, having trouble
nmz787
Posts: 24
As best I can figure is that either I'm not setting my code structure correctly, or a cog can't access a register simultaneously... here's my code:
I've even tried doing the PIN MUXing all in the first cog, but that doesn't help
con _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 pub main cognew(@masterClock, 0) cognew(@masterClock1, 0) dat org 0 'start of the program storage locations masterClock or dira, masterClockPin 'pin now sets lines 0 and 1 as outputs :loop xor outa, masterClockPin 'sets output 0 on and 1 off jmp #:loop 'go back and loop. masterClock1 or dira, shPin 'pin now sets lines 0 and 1 as outputs :loop1 xor outa, shPin 'sets output 0 on and 1 off jmp #:loop1 'go back and loop. masterClockPin long 1<<8 shPin long 1<<9
I've even tried doing the PIN MUXing all in the first cog, but that doesn't help
Comments
BTW the period of the toggled GPIO is about 6MHz... (I have a 6MHz crystal connected, so maybe my setup is incorrect?)
For synchronisation there are several different ways of doing it. The most commonly used one is waitcnt. Meaning both cogs are given a cnt target in the future and sync on that. The ~42ns do originate from the nop which takes 4 cycles at 1/96MHz = 10.416ns (total 41.6ns).
I was trying to do something very similar to this with an Atmega, and made no progress for the last 3 days trying to use interrupts (what I really need is a toggle 100-1000ns before the other GPIO toggles) and I was failing. I bet I could accomplish what I want with the Atmega, but I'm really a biologist developing some lab equipment, so the less time I spend on electronics, the more time I have actually developing the equipment I want!
Thanks again! I'm already happy with the Propeller and this forum!
Thanks again!
I actually don't need to toggle the second line all the time, but when I do toggle the second it needs to be synchronized (like I said 100-1000ns before the clock goes low). I am controlling a CCD, and one GPIO line needs to go low for 1 period of the constantly toggled GPIO line. This begins the readout of the CCD, it looks like this in ASCII art:
_|¯|_|¯|_|¯|_|¯|_|¯|_|¯|_|¯|_|¯|_.......
¯¯|___|¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯.......