Can PBP & 16f88 really do 9600,8,E,1


Closed Thread
Results 1 to 39 of 39

Hybrid View

  1. #1
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    I don't see what is causing the syntax error.

    There is a sample program that shows various inputs using SerIn here...I believe HSerIn uses the same syntax.

    Also, lose the quote marks - you are waiting for $AA (i.e. 0xaa, a hex byte, binary %10101010) not ascii AA which would be "AA" without the $.
    Last edited by dhouston; - 23rd October 2009 at 16:00.

  2. #2


    Did you find this post helpful? Yes | No

    Default

    Nope still no joy won't compile.

    Just to clear up any confusion I'm waiting for a byte value to appear on the usart ($87) not an ascii string. I then want to gather the following data into the array. It's 9600 8,E,1 (24 bytes total in the packet inc the $87 start byte)

    This compiles

    Code:
    HSERIN [WAIT ($87)]		'Wait for byte $87 (135 Dec)
    
    as does this
    
    HSERIN [WAIT (135)]		'Wait for byte $87 (135 Dec)
    Looks like I will have to wait for the identifier then use another HSERIN command to get the following bytes. Problem is there is no break in the data and it follows on immdiately after the $87 if received. I hope it doesnt miss the start of the second byte

    I'll try this it compiles corectly.
    Code:
    HSERIN [WAIT ($87)]		'Wait for packet start Byte $87  
    HSERIN [STR BCMDATA\23]		'Receive following 23 bytes into array BCMDATA

  3. #3
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default

    Can you show your whole program that you are trying to compile? And also your configs?

    This compiles perfectly well here:
    Code:
    DATAIN var byte[11]
    
    HSERIN [WAIT($AA), STR DATAIN\11]
    http://www.scalerobotics.com

  4. #4
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    What version of PBP? Using MPASM or PM?

    I get the same syntax error (Expected "]") on a similar (mine includes a timeout label & value) statement using PBP 2.50 and MPASM.
    Code:
    HSerIn 15,init,[WAIT($FF,$05),addr)
    Last edited by dhouston; - 23rd October 2009 at 17:40.

  5. #5
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by dhouston View Post
    I get the same syntax error (Expected "]") on a similar (mine includes a timeout label & value) statement using PBP 2.50 and MPASM.
    Code:
    HSerIn 15,init,[WAIT($FF,$05),addr)
    Sorry, the closing ")" was a typo - my router quit yesterday and I had to manually type that line instead of copying it across my network.

    The reason my test failed was because addr was not declared. The error message is a bit cryptic.

    Have you declared the correct number of array elements for DATAIN?

  6. #6


    Did you find this post helpful? Yes | No

    Default

    My complete code is here. Sadly I have now deleted the troublesome line and replaced it with two lines. I am using PBP 2.50 and PM

    Code:
    '-------------------------------------
    ' PBP BCM CODE 22/10/09 V.04 8mhz
    '-------------------------------------
    
    @ DEVICE PIC16F88,INTRC_OSC_NOCLKOUT
    @ DEVICE PIC16F88,PROTECT_OFF
    @ DEVICE PIC16F88,WDT_OFF
    @ DEVICE PIC16F88,PWRT_ON
    @ DEVICE PIC16F88,MCLR_ON
    @ DEVICE PIC16F88,BOD_OFF
    @ DEVICE PIC16F88,LVP_OFF
    @ DEVICE PIC16F88,CPD_OFF
    @ DEVICE PIC16F88,DEBUG_OFF
    @ DEVICE PIC16F88,CCPMX_OFF
    
    DEFINE OSC 8 			'Set oscilator speed to 8mHz 
    OSCCON=%01111000 		'8 Mhz
    
    'DEFINE OSC 4 			'Set oscilator speed to 4mHz
    'OSCCON =%01100000		'4 Mhz
     
    DEFINE HSER_BAUD 9600		'Set Baud rate to 9600bps
    DEFINE HSER_BITS 9		'Set to 9 bit mode
    DEFINE HSER_EVEN 1		'Set Even Parity
    DEFINE HSER_CLROERR 1 		'Clear overflow error automatically
    
    ANSEL = 0 			'ALL DIGITAL
    CMCON = 7 			'COMPARATORS OFF
    INTCON = 0 			'Disable interrupts
    TRISB = %00000100 		'SET PORTB RB2(RX) as input, others to OUTPUT
    TRISA = %11111111 		'SET PORTA AS INPUTS
    
    'Variables
    
    BCMDATA VAR BYTE[12]		'Define BCMAADATA as a byte array (12 Bytes) 
    Count1 VAR BYTE			'Define Count1 as a byte variable (Used in For/Next Loops)
    CheckSum VAR BYTE		'Define CheckSum as a byte variable
     
    
    Commloop: 				'Start of Communications Loop
    
        HSERIN [WAIT ($87)]		'Wait for Packet start Byte $87   
    	HSERIN [STR BCMDATA\11]		'Receive 11 bytes into array BCMDATA
    
    	'Gosub CalcSum			'Gosub CalcSum to Calculate Checksum 
    
        Hserout [$87]               'Transmit Packet start Byte $87
    	HSEROUT [str BCMDATA\11]	'Transmit 11 bytes from array BCMDATA
    	           	
        HSERIN [WAIT ($AA)]		'Wait for Packet start Byte $AA   
    	HSERIN [STR BCMDATA\11]		'Receive 11 bytes into array BCMDATA
    
    	'Gosub CalcSum			'Gosub CalcSum to Calculate Checksum 
    
        Hserout [$AA]               'Transmit Packet start Byte $AA
    	HSEROUT [str BCMDATA\11]	'Transmit 11 bytes from array BCMDATA   
    	
    	
    	Pause 32				'Pause for 16ms
        HSEROUT [$AA,$10,$00,$00,$00,$20,$40,$61,$10,$01,$00,$74]		'Transmit 12 bytes 
        pause 32                'Pause for 16ms
        HSEROUT [$87,$40,$58,$15,$6E,$10,$01,$32,$2F,$2F,$04,$39]		'Transmit 12 bytes 
        pause 32                'Pause for 16ms
    
        goto CommlooP			'Goto Loop      
        
    CalcSum:					'Calculate Packet CheckSum Routine
    	CheckSum = 0				'Clear CheckSum Variable
    	For Count1 = 0 to 10			'For Count1 = 0 to 10 (Start 11 byte loop)
    	CheckSum = CheckSum + BCMDATA[Count1]	'Add Bytes
    	Next Count1				'Repeat until 11 bytes added
    	CheckSum = NOT CheckSum			'Not CheckSum
    	CheckSum = CheckSum + 1			'Add 1 to CheckSum
    	BCMDATA[12] = CheckSum AND $7F 		'AND result
    	Return					'Return 	
    
    
    END
    However i have just tried this.

    Code:
     HSERIN [WAIT($87), str BCMDATA\11]		'Receive 12 bytes into array DATAIN
    And it compiles correctly, might have been me with a typo!!!!! Arrggh. I let you know. Thanks for the help so far. This program is just proof of concept at the moment I know the "gosub" is not called at the moment. I'm trying to get the hserin/out working first.

    Anything with my configs or program that would stop a pickit2 icsp working I can't get that to work for love or money, but the chip works fine in a standalone programmer. I've checked the circuit and pickit2 voltages and it all looks fine. Just can't find device 99% of the time.

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by retepsnikrep View Post
    Anything with my configs or program that would stop a pickit2 icsp working I can't get that to work for love or money, but the chip works fine in a standalone programmer. I've checked the circuit and pickit2 voltages and it all looks fine. Just can't find device 99% of the time.
    Do you have capacitors across VDD and VSS??
    Dave
    Always wear safety glasses while programming.

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 83
    Last Post: - 4th October 2021, 12:55
  2. PBP migration from 16F88 to 16F1827
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 21st June 2010, 18:14
  3. PBP, ASM and LST files
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th January 2010, 13:43
  4. Compiler differences between PBP 2.33 & 2.46
    By nikopolis in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 2nd May 2006, 19:01
  5. Newby- PBP wont compile for 18F (MPLAB)
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 17th December 2005, 23:30

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts