PDA

View Full Version : arraywrite not found when programming in v2.6?



jellis00
- 19th March 2010, 03:41
I am trying to create an array by using the new ARRAYWRITE statement in PBP version 2.6 to add received characters from an RS232 interface to the string until a linefeed character is received.
When I type arraywrite in my MCSPlus editor, it does not automatically convert to all caps as a reserved word, which led me to believe that I didn't have my MCSPlus editor set to find and use PBP version 2.6. However when I went to the Compile/Program Options in MCSPlus, version 2.6 was already set as the compiler.
Is there any reason why MCSPlus won't find version 2.6 when selected, thus preventing me from using ARRAYWRITE?
Here is my code.


;--- if you un-comment these, you must comment the ones in the .inc file--
ASM ; 16F887, 8mhz crystal
__CONFIG _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
ENDASM
OSCCON = %01110000 ' Select internal oscillator at 8 MHz
Include "Modedefs.Bas"
INCLUDE "ALLDIGITAL.pbp" ' Sets all registers for digital ops.
' User must make sure the AllDigital.pbp file
' is in same directory location as this source
' code before compiling.
'DEFINE SHOWDIGITAL 1 ' When uncommented will show analog settings
' in Assembler Results window.
' A/D & Comparators disabled for digital ops
' All of these statements should be commented out when using the
' INCLUDE "AllDigital.pbp" statement to set digital ops.
'ADCON1 = %00001111
'CMCON = 7

DEFINE OSC 8
'Register Settings
TRISA = 0 ' PortA connections are used for LCD interface
TRISB = %00000000 ' Set PORTB to outputs as test LEDs
TRISC.0 = 0 ' PortC.0 is used for a Heartbeat LED
TRISC.2 = 0 ' PortC.2 is used for the LCD R/W connection
TRISC.6 = 1 ' EUSART control will automatically reconfigure
TRISC.7 = 1 ' these pins from input to output as needed.

DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
' RCSTA.7 = SPEN = 1 for Serial port enabled (configures
' RX/DT & TX/CK pins as serial port pins).
' RCSTA.4 = CREN = 1 for Asynchronous Continuous Receive
' Therefore RCSTA = %10010000 = 90h
DEFINE HSER_TXSTA 20h ' Enable transmit, 8-bit, Asynchronous mode
' TXSTA.5 = TXEN = 1 for Transmit enabled
' TXSTA.4 = SYNC = 0 for Asynchronous mode
' TXSTA.2 = BRGH = 0 for High Speed Asynchronous Baud Rate
' Therefore TXSTA = %00100000 = 20h
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
DEFINE HSER_SPBRG 51 ' 9600 Baud @ 8MHz, 0.16%, , 51 = 33h = %00110011
'SPBRGH = 0
BAUDCTL.3 = 1 ' Enable 16 bit baudrate generator

' Make sure that SW6.8 on the EasyPic6 is set to ON position before powerup.
' Make sure that SW7.1 & SW8.1 on EasyPic6 are set to ON before powerup.
' Initialize the display

Pause 500 ' Wait for LCD to startup after power on
GOSUB InitializeDisplay

PORTB = 0 ' Turn off the LEDs
HIGH PORTB.4 ' Blink the one Test LED as proof MCU is running
PAUSE 500 ' at time of power up.
LOW PORTB.4

' Declare variables
i VAR Byte ' Index for rcvd word array element
string VAR BYTE[8] ' 8 element array containing received characters
X VAR BYTE ' Variable holds received character from RS232
i = 0
For i = 0 to 7
string[i] = 0 ' Clear all elements in the string array
Next
Clr_display:
LCDOUT $fe,1 ' Clear the LCD display
LCDOUT $fe,$80 ' Move cursor to 1st line of LCD
mainloop:
PORTC.0 = 1 ' Blink Heartbeat LED during mainloop
hserin [x]
'HSERIN [DEC X]
PORTB.5 = 1 ' Turn on PortB.5 LED if this statement is executed
' as a test of receiving a character
If X <> $a Then ' If X=linefeed, end of string reached..clear display
arraywrite string[i],8,Clr_display,[x]
LCDOUT $fe,$80+i, ' Append character to 1st line display string
i = i+1 ' Increment array element index
Else
LCDOUT $fe,1 ' Clear LCD display on receipt of line feed
LCDOUT $fe,$80 ' Move cursor to 1st line of LCD
i = 0 ' Reset array element index
Endif
Pause 500 ' Wait .5 second
PORTC.0 = 0
HSEROUT [DEC X,$d,$a] ' Loopback of received character + CR + LF
PORTB.6 =1 ' Turn on PortB.6 LED if this statement is executed
' as a test of HSEROUT having sent a character.
GOTO mainloop

mackrackit
- 19th March 2010, 04:27
What happens if YOU make the command capitals and compile?
Does it work or returns an error?

ScaleRobotics
- 19th March 2010, 04:37
arraywrite string[i],8,Clr_display,[x]
[/CODE]

I don't think you can format your Arraywrite like that.

See Darrel's explanation here:
http://www.picbasic.co.uk/forum/showpost.php?p=82995&postcount=4

jellis00
- 19th March 2010, 04:56
What happens if YOU make the command capitals and compile?
Does it work or returns an error?
If I capitalize the whole word it still isn't "bolded" by the editor as is normally done for legitimate statements. However, when I compile it when it is all CAPS it does compile without errors. Is this because MCSPlus doesn't recognize the ARRAYWRITE statement and therefore doesn't bold it, but the compiler still accepts it??

jellis00
- 19th March 2010, 04:59
I don't think you can format your Arraywrite like that.

See Darrel's explanation here:
http://www.picbasic.co.uk/forum/showpost.php?p=82995&postcount=4
I see what you are saying in DT's post.
What I want to do is append each character that is received over the RS232 interface by HSERIN as an additional element of the array. Is their another way to build the array if I can't do it this way?

mackrackit
- 19th March 2010, 05:00
If I capitalize the whole word it still isn't "bolded" by the editor as is normally done for legitimate statements. However, when I compile it when it is all CAPS it does compile without errors. Is this because MCSPlus doesn't recognize the ARRAYWRITE statement and therefore doesn't bold it, but the compiler still accepts it??
That would be my guess, but I do not really know.

Heckler
- 19th March 2010, 15:54
I was told by the good folks at Melabs that MCS (and I presume MCSplus also) does not recognize the new statements, ARRAYREAD/ARRAYWRITE. But it will compile them correctly as long as you have your sintax correct.

There is a new version of MCS in the works that will be aware of the ARRAYREAD/WRITE statements and will display them correctly. That is really all the IDE (integrated development environment) is doing is "colorizing" the text, and providing some low level tips on syntax.

So go ahead and use the new statements and if syntax is good it will compile and run correctly.

I did find this to work for me.

good luck
Dwight