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.
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




Bookmarks