Thursday, February 20, 2014

A GA144, a 10MHz ceramic resonator and an LED.

I've found some time to continue my dabbling in the intricacies of the GA144 chip. I spent too many hours trying to copy a demo which used a 32KHz watch crystal to provide accurate clocking for a couple of nodes in the chip. In the end I was unable to get the crystal to sustain oscillation for longer than about 30 seconds. And the nature of the component meant I was unable to monitor the oscillations with an oscilloscope. So I switched to using a 10MHz ceramic resonator and there is a similar demo in the ArrayForth sample code. The main difference is that this demo works! (Ceramic resonators are apparently easier to drive.)

I was also experimenting with the PWM demo application in the User Guide Ch. 9 and there is a small side note to the effect that maybe the constant used to set the LED's brightness ought not to be simply a linear increase but perhaps a Fibonnaci sequence because we perceive brightness increases logarithmically.

So I wondered if I could make the oscillator node send a signal every 100ms to its neighbour to cause the brightness constant to increase in a Fibonacci sequence and thus cause the LED brightness to increase slowly in an apparently "linear" fashion.

A couple of minor details: I used node 417 as the oscillator and attached a Murata CST 10.00 MHz resonator between pin 417.17 and ground. I used node 317 to drive the LED with the anode connected to the 3.3V supply from USB port A and the cathode connected to pin 317.17. (On the EVB001 eval board 317.17 and 417.17 feed out to header J21.) (Refer User Guide Ch. 9 for details of LED connections.)

The following code is very similar to that given in Block 956 in the ArrayForth sample code. However I incorporated changes as suggested by Chuck Moore in his StrangeLoop 2013 talk. And I added bigger and bigger delays between signals to node 317 (via up port). In the end the delay is a million to one so that the 10MHz oscillation is reduced to a 10Hz signal.

Block 864
init waits for a commencement signal from node 317 via the up port, loads the stack with 8 numbers and sets them to become a repeating stack array.

go runs 10 hi-low pulses to the resonator then drops into an infinite loop which calls pump and ring to keep the resonator pulsing and periodically outputs an instruction to node 317.

864 list 
417 orig tx osc 417 node 0 org
drive
 00 4n drop !b !b for unext ;
pump
 03 4n !b @ drop !b !b drop ;
ring
 05 4n !b @,
.........drop drop drop drop ;,
,

go 07 9 for drive drive next 0c .,
...
begin 0d,
......
999 for 999 for,
.........
pump pump ring ring,
......
next next,
......
17 a up a!,
.........@p 19 ; .. 1a ! a!,
...end,
,
init 1c up a! @
xx 1e drop io b! left a!,
7 dup dup or 20000 800,
6 dup dup or 30000 over,
dup dup drop drop go ;,
2c reclaim

Block 866
init sets the a and b registers and loads the stack with 1 and 1, the first numbers in the Fibonacci sequence, then sends an instruction to node 417 causing it to commence the oscillation loop.

pol tests if the up port has a signal on it. If so, elements on the stack being used by the cyc routine are dropped and the next value in the Fib sequence is calculated. If the Fib value becomes "negative", the stack is reset to 1 and 1 otherwise the Fib number is left on the stack to be used by cyc.

cyc uses the PWM method explained in the User Guide. The stack contains a value between 0 and 20000 hex representing brightness i.e. 0 (1) means no light, 20000 means full on/max. brightness.

866 list 
pwm demo 317 node 0 org br

init io b! up a! 1 dup dup dup,
.....
@p . .. 06 ; 07 !,
pol 08 @b 200 uw and if,
...0b up b! @b drop drop drop,
...
+ -if 1 dup dup dup,
...
then over over dup dup dup or,
...
io b! then 15 drop br


cyc ie- 1ffff and over . + -if cr
...19 .....20000 !b pol ; cr
...
1c then 10000 !b pol ; 1f                  

Block 862
is the loader block.

862 list
loader template
host load loader load,
using default ide paths,
kill boots 0 708 hook 0 -hook,
path to 317 0 317 hook,
,
setup application,
417 +node 417 /ram 1c /p,
317 +node 317 /ram 0 /p,
panel pause 0 ship upd ?ram 


                  

No comments: