Bean...a question or two..please...

in Propeller 1
Reference propbasic..How many "LONG(s) are allowed in a COG...and are there more of them used in COG 0 to run or convert the propbasic to spin? I have notice an ERROR at the bottom of the download page that says I have exceeded the number of longs by 27. The program still loads, but in this particular, COG, I do get strange results..mainly, some of the SEROUT to the LCD, does not display...
Also, is there some "secret" way of using the SEROUT command, in the same manner as using the command in the Basic Stamp. Meaning with a comma delimiter between each instruction, instead of using the SEROUT command with only one instruction at a time...? Hope I am making since..thanks...DennO
Also, is there some "secret" way of using the SEROUT command, in the same manner as using the command in the Basic Stamp. Meaning with a comma delimiter between each instruction, instead of using the SEROUT command with only one instruction at a time...? Hope I am making since..thanks...DennO
Comments
PropBasic is NOT converted to spin. It is converted directly to assembly language on the PC.
You need to put SEROUT in a subroutine to save code space.
Bean
So, when I "build" my program and at the bottom it says "Program size is 3380 LONGS" Is that everything all together. I notice if I should exceed a certain amount of the Program size, some where around 3470 LONGS, I will still get a successful download, to RAM and even EEPROM, but the last part of the program will not work...the part before I ran out of room. I am guessing. Is that right?
BTW, there is infact 199 lines of code in the complete program...as stated below...so the complier did see the whole program, but just did not compile the whole program?
And, thanks for all your time and effort in building PROPBASIC...as some of us are just "basic" people...DennO
PropBasic Version 00.01.48 Aug 9, 2018 Finished Compile. 199 Lines Read, 910 Lines Generated, 0 Warnings, 0 Errors. Brads Spin Tool Compiler v0.15.3 - Copyright 2008,2009 All rights reserved Compiled for i386 Win32 at 08:17:48 on 2009/07/20 Loading Object LCDdisplay_SE Loading Object LCD_1.spin Loading Object temperature_1.spin Loading Object temperature_2.spin Lo ading Object volt_measure.spin Program size is 3380 longs Compiled 1176 Lines of Code in 0.076 Seconds
Mike R...
As a footnote, I like to set alot of things to CONSTANTS, and use descriptive words to describe various variables...makes for easier reading of the code...I just purchased a FLIP, and have an embedded project for that. Presently, using the PROP Activity board that was sent to me for free, many years ago, when the PROP first came out...even with the Manual..1.0.
Readers, please don't take this the wrong way, but I don't like using other peoples "OBJECT(s)" in SPIN, as I find alot of them very hard to read, especially, in assembly language. That is why I always liked PBASIC for the stamp, and now, propbasic for the prop..
pmrobert, one last question...is the STACK directive necessary in propbasic (LMM mode?)
The next thing I need to figure out is how to set up a SUB ROUTINE for the SEROUT out commands to save code space.
thank you again...DennO
DEVICE P8X32A, XTAL1, PLL16X XIN 5_000_000 'STACK 100 '========CONSTANTS============ baud CON "N9600" carr_return CON 13 clrLCD CON 12 'clear the screen on the lcd posCMD CON 16 'position the curser command hideCUR CON 4 'hide the curser command blinkCUR CON 6 'blink the curser command degreeSYM CON 223 'the "degree" symbol receive_data CON 255 backLTon CON 14 'turn the back light on backLToff CON 15 'turn the back light off brightness_ctl CON 27 quarter_bright CON 48 half_bright CON 49 three_quarter_bright CON 50 full_bright CON 51 beep CON 7 'beep command right_align CON 18 'RIGHT ALIGN COMMAND start_big_char CON 2 end_big_char CON 3 astrike CON 42 block_char CON 134 carReturn CON 13 'carriage return command blank_char CON 32 left_arrow CON 127 right_arrow CON 126 LR_arrow CON 131 LL_arrow CON 128 UR_arrow CON 129 UL_arrow CON 130 down_arrow CON 132 up_arrow CON 133 equal_sign CON 61 first_line CON 64 second_line CON 104 no_char CON 0 '======== HUB VARIABLES============== degrees_1 HUB LONG 'location of temp_1 data temp_1DEC HUB string(3) degrees_2 HUB LONG'LONG 'location of temp_2 data temp_2DEC HUB string(3) volt_location HUB LONG 'location of volt data tenth_location HUB LONG hunds_location HUB LONG actualVOLT HUB string(10) actualVOLTtenth HUB string (10) actualVOLThunds HUB string (10) '========PIN ASSIGNMENTS======== ' 'Assignments of pin go in each COG that is using that pin.. '============CODE=============== LCD_1 TASK temperature_1 TASK temperature_2 TASK volt_measure TASK LED_blue PIN 1 PROGRAM Start 'this is running in COG 0 Start: COGINIT LCD_1, 7 'cog 7 COGINIT temperature_1, 5 'cog 5 COGINIT temperature_2, 6 'cog 6 COGINIT volt_measure, 4 'cog 4 DO 'this do/loop is just something for COG 0 to do... PAUSE 500 TOGGLE LED_blue PAUSE 500 LOOP END '=============================================== TASK LCD_1 LMM 'this TASK is running in COG 7 temp_1 VAR LONG 'the temp_1erature data, itself.. temp_2 VAR LONG stringVOLT VAR LONG stringVOLTtenth VAR LONG stringVOLThunds VAR LONG LCD_data_out PIN 2 'Define a string variable: ' string1 HUB STRING(3) 'Use STR to place the ASCII' representation of temp_1's value into a string ' string1 = STR temp_1,3 'THEN display it. ' SEROUT LCD_data_out, baud, string1 SEROUT LCD_data_out, baud, clrLCD SEROUT LCD_data_out, baud, beep SEROUT LCD_data_out, baud, backLTon SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 64 SEROUT LCD_data_out, baud, "TEMPERATURE IS" SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 84 SEROUT LCD_data_out, baud, "TEMPERATURE IS" SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 104 SEROUT LCD_data_out, baud, "VOLTAGE=" SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 119 SEROUT LCD_data_out, baud, "volts" DO RDLONG degrees_1, temp_1 'reading the temperature data that is in the HUB PAUSE 100 temp_1DEC = STR temp_1,3 RDLONG degrees_2, temp_2 'reading the temperature data that is in the HUB PAUSE 100 temp_2DEC = STR temp_2,3 RDLONG volt_location, stringVOLT PAUSE 100 RDLONG tenth_location, stringVOLTtenth PAUSE 100 RDLONG hunds_location, stringVOLThunds PAUSE 100 actualVOLT = STR stringVOLT, 1 actualVOLTtenth = STR stringVOLTtenth,1 actualVOLThunds = STR stringVOLThunds,1 SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 79 SEROUT LCD_data_out, baud, temp_1DEC SEROUT LCD_data_out, baud, degreeSYM SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 99 SEROUT LCD_data_out, baud, temp_2DEC SEROUT LCD_data_out, baud, degreeSYM SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 112 SEROUT LCD_data_out, baud, actualVOLT SEROUT LCD_data_out, baud, "." SEROUT LCD_data_out, baud, actualVOLTtenth SEROUT LCD_data_out, baud, actualVOLThunds LOOP ENDTASK LCD_1 '================================================================ TASK temperature_2 LMM 'this TASK is running in COG 6 again: temp_2 VAR LONG 'the temp_1erature data, itself.. temp_2 = 125 DO temp_2 = temp_2 + 1 WRLONG degrees_2, temp_2 PAUSE 200 LOOP UNTIL temp_2 >= 400 DO temp_2 = temp_2 - 1 WRLONG degrees_2, temp_2 PAUSE 200 LOOP UNTIL temp_2 <= 0 GOTO again ENDTASK temperature_2 '================================================================ TASK temperature_1 LMM 'this TASK is running in COG 5 temp_1 VAR LONG 'the temp_1erature data, itself.. temp_1 = 114 DO temp_1 = temp_1 + 1 WRLONG degrees_1, temp_1 PAUSE 200 LOOP UNTIL temp_1 >= 400 ENDTASK temperature_1 '================================================================ TASK volt_measure LMM ' this is running in COG 4 ADC_Clk PIN 3 LOW ' MCP3204.11 ADC_Dout PIN 4 LOW ' MCP3204.10 ADC_Din PIN 5 LOW ' MCP3204.9 ADC_CS PIN 6 HIGH ' MCP3204.8 MCPValue VAR LONG voltDEC VAR LONG stringVOLT VAR LONG stringVOLTtenth VAR LONG stringVOLThunds VAR LONG DO LOW ADC_CS ' Enable MCP3204 PAUSEUS 100 SHIFTOUT ADC_Din, ADC_Clk, MSBFIRST, %11000\5 ' Select CH0, Single-Ended SHIFTIN ADC_Dout, ADC_Clk, MSBPOST, MCPValue\13 ' Read ADC HIGH ADC_CS ' Disable ADC LOW ADC_Clk stringVOLT = MCPValue/819 stringVOLTtenth = MCPValue//819 stringVOLTtenth = stringVOLTtenth * 10 stringVOLTtenth = stringVOLTtenth/819 stringVOLThunds = stringVOLTtenth //819 stringVOLThunds = stringVOLThunds * 10 stringVOLThunds = stringVOLThunds/819 WRLONG volt_location, stringVOLT PAUSE 100 WRLONG tenth_location, stringVOLTtenth PAUSE 100 WRLONG hunds_location, stringVOLThunds PAUSE 100 LOOP ENDTASK volt_measure
InitStr DATA clrLCD, beep, backLTon, posCMD, 64, "TEMPERATURE IS", posCMD, 84, "TEMPERATURE IS", posCMD, 104, "VOLTAGE=", posCMD, 119, "volts", 0
SEROUT LCD_data_out, baud, InitStr
Something like that...
Bean
And, using propbasic, what are the total number of LONG(s) available to use in programming. Right now, I am at 6720 LONGS in this little test program in my previous post/thread..
LCD_data DATA clrLCD, beep, backLTon, posCMD, 64, "TEMPERATURE IS", posCMD, 84, "TEMPERATURE IS", posCMD, 104,"VOLTAGE=", posCMD, 119, "volts", 0 DO RDLONG LCD_data_location, LCD_data PAUSE 100 SEROUT LCD_data_out, baud, LCD_data LOOP UNTIL LCD_data = 0
RDLONG LCD_data, LCD_data_location
Edit: Oops! I see I'm wrong. The arguments to the PropBasic RDLONG are backwards from the PASM instruction. Sorry!
SEROUT LCD_data_out, baud, LCD_data
Bean
DEVICE P8X32A,XTAL1,PLL16X FREQ 80_000_000 LetterA CON 65 LetterB CON 66 LCD_Pin PIN 30 HIGH LCD_Data DATA LetterA,LetterB,67," Testing...", 13, 0 PROGRAM Start Start: PAUSE 5000 SEROUT LCD_Pin, T9600, LCD_Data GOTO Start END
The LCD may need a delay after some commands like clrLCD and Beep. I don't know...
If you want to send a character at a time you'll have to do something like:
LCD_Data DATA "This is a test", 13, 0 StrPos VAR LONG Char VAR LONG StrPos = 0 DO RDBYTE LCD_Data(StrPos), Char INC StrPos IF Char = 0 THEN EXIT SEROUT LCD_Pin, Baud, Char IF Char = clrLCD THEN PAUSE 10 ELSEIF Char = beep THEN PAUSE 100 ENDIF LOOP
Bean
LCD_data LDATA clrLCD,beep,backLTon,posCMD,64,"TEMPERATURE IS",posCMD,84,"TEMPERATURE IS",posCMD,104,"VOLTAGE=",posCMD,119,"volts",0
However when I try to load the following line as data, the "STRINGS" will not display...as example..the "temp_1DEC", "temp_2DEC", "actualVOLT", actualVOLTtenth, and actualVOLThunds....and so on...
LCD_data_2 DATA posCMD,79,temp_1DEC,degreeSYM,posCMD,99,temp_2DEC,degreeSYM,posCMD,114,actualVOLT,".",actualVOLTtenth,actualVOLThunds,0
The "degreeSYM" and the "." do place in the proper place on the display...I have tried many different things, but no joy as of yet...So, any thoughts on how to pass a DATA string which is just numbers...the following is the code that runs in a DO?LOOP. The variables in the loop get refreshed each iteneration through the loop. But they will not display on the LCD. The loop runs as coded, and the variables will display properly, however, I am wondering if there is a way, using less SEROUT's. I hope I am making sense. Readers please keep in mind that this is just a snippit of the program. Basicly, I am just teaching myself PROPBASIC, and trying to run all eight COGS in one program...
DO RDLONG degrees_1, temp_1 'reading the temperature data that is in the HUB PAUSE 100 temp_1DEC = STR temp_1,3 ' tempVAL = VAL temp_1DEC RDLONG degrees_2, temp_2 'reading the temperature data that is in the HUB PAUSE 100 temp_2DEC = STR temp_2,3 RDLONG volt_location, VOLT PAUSE 100 RDLONG tenth_location, VOLTtenth PAUSE 100 RDLONG hunds_location, VOLThunds PAUSE 100 actualVOLT = STR VOLT, 1 actualVOLTtenth = STR VOLTtenth,1 actualVOLThunds = STR VOLThunds,1 RDLONG volt_location_3v, VOLT_3v PAUSE 100 RDLONG tenth_location_3v, VOLTtenth_3v PAUSE 100 RDLONG hunds_location_3v, VOLThunds_3v PAUSE 100 actualVOLT_3v = STR VOLT_3v,1 actualVOLTtenth_3v = STR VOLTtenth_3v,1 actualVOLThunds_3v = STR VOLThunds_3v,1' ' LCD_varables DATA posCMD,79, tempVAL ' SEROUT LCD_data_out, baud, LCD_varables SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 79 SEROUT LCD_data_out, baud, temp_1DEC SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 99 SEROUT LCD_data_out, baud, temp_2DEC SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 114 SEROUT LCD_data_out, baud, actualVOLT SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 116 SEROUT LCD_data_out, baud, actualVOLTtenth SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 117 SEROUT LCD_data_out, baud, actualVOLThunds SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 134 SEROUT LCD_data_out, baud, actualVOLT_3v SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 136 SEROUT LCD_data_out, baud, actualVOLTtenth_3v SEROUT LCD_data_out, baud, posCMD SEROUT LCD_data_out, baud, 137 SEROUT LCD_data_out, baud, actualVOLThunds_3v LOOP
Thanks...and this is fun....DennO