multiple cogs and simple serial ... ???
I took a copy of Jon Williams' "Serial_LCD" and used it to create a driver object (K107_LCD.spin - see below attachment) for my K107 LCD Controller board using the Anderson chip. It works just fine using, additionally the "simple_serial" and "simple_numbers" objects.
I then created a K107_LCD_Demo3.spin. In it I created a generalized display demo, which instantiated a K107_LCD obejct , initialized for port, baudrate, display geometry, etc and then runs it.. As a simple "call" it works fine. I have three displays I am playing with now a 2x16 and a4x20 backlits displays and a 2x24 non-backlit display. Any of them by themselves works. If I instatiate 3 different objects and make three copies of the routines one using each object that works for all three too.
However my goal is to use the PRC baord to drive several of these displays simultaneously as a demo. I wanted to make a generalized routine, pass parameters and start, in this case each of three in a separate cog. I hav attaced the whole code file below (K107_LCD_Demo3.spin) but here is a snippet ...
The code as shown produces no output to the displays. HOWEVER, if I comment out any two of the COGNEW calls the one that is there works like a champ. I know I am missing something obvious here. Can someone please put me out of my misery and tell me what it is that I missed?
thanks ...
p.s. Chip, I LOVE SPIN, the more I work with it, the more other languages annoy me! Its simple elegance is incredible. It lets me get down to the business of producing working code without having to deal with the arcane minutia prevalent in so many languages, even PBASIC comes off looking like Perl in comparison! <grin>
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cheers ... brian riley, n1bq, underhill center, vermont
See the K107 Serial LCD Controller at
www.wulfden.org/k107/
I then created a K107_LCD_Demo3.spin. In it I created a generalized display demo, which instantiated a K107_LCD obejct , initialized for port, baudrate, display geometry, etc and then runs it.. As a simple "call" it works fine. I have three displays I am playing with now a 2x16 and a4x20 backlits displays and a 2x24 non-backlit display. Any of them by themselves works. If I instatiate 3 different objects and make three copies of the routines one using each object that works for all three too.
However my goal is to use the PRC baord to drive several of these displays simultaneously as a demo. I wanted to make a generalized routine, pass parameters and start, in this case each of three in a separate cog. I hav attaced the whole code file below (K107_LCD_Demo3.spin) but here is a snippet ...
The code as shown produces no output to the displays. HOWEVER, if I comment out any two of the COGNEW calls the one that is there works like a champ. I know I am missing something obvious here. Can someone please put me out of my misery and tell me what it is that I missed?
PUB main waitcnt(clkfreq + cnt) cognew(displayLCD(0, 9600, 216, 9, $10, 0), @stack1) cognew(displayLCD(2, 9600, 420, 9, -$10, $80), @stack2) cognew(displayLCD(4, 9600, 224, 0, 0, 0), @stack3) PRI displayLCD ( pin, baud, geometry, iCount, iStep, iStart) | i, idx, rpt, ccnt if lcd.start(pin, baud, geometry) lcd.cursor(0) ' cursor off lcd.intoBigNum(3) lcd.outofBigNum lcd.cls ..... details extraneous to the issue deleted .... repeat idx from $40 to ccnt ' loop to display 15 chars 1ms pacing lcd.putc (idx) waitcnt(clkfreq / 1000 + cnt) ' pad with 1 ms waitcnt(clkfreq + cnt) i += iStep waitcnt(2*clkfreq + cnt)
thanks ...
p.s. Chip, I LOVE SPIN, the more I work with it, the more other languages annoy me! Its simple elegance is incredible. It lets me get down to the business of producing working code without having to deal with the arcane minutia prevalent in so many languages, even PBASIC comes off looking like Perl in comparison! <grin>
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cheers ... brian riley, n1bq, underhill center, vermont
See the K107 Serial LCD Controller at
www.wulfden.org/k107/
spin

10K
Comments
Easiest thing to do is to declare an array of LCD drivers like: 'OBJ lcd : "K107_LCD"' and in your displayLCD routine, use an additional parameter to specify which LCD driver copy to use. Only the VARs are duplicated for each array element. Only one copy of the methods is used. There should also be duplicates of any VARs used by objects referenced by "K107_LCD".
I specifying different pins for each call, I suspected as much about the objects. B
So ... somethiing like this
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cheers ... brian riley, n1bq, underhill center, vermont
See the K107 Serial LCD Controller at
www.wulfden.org/k107/
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
cheers ... brian riley, n1bq, underhill center, vermont
See the K107 Serial LCD Controller at
www.wulfden.org/k107/