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


Closed Thread
Results 1 to 39 of 39

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    Thanks I've made some changes to my code and it is working sort of.

    Code:
    '-------------------------------------
    ' PBP Fake BCM CODE 21/10/09 V.04
    '-------------------------------------
    
    @ DEVICE PIC16F88,INTRC_OSC_NOCLKOUT
    @ DEVICE PIC16F88,PROTECT_OFF
    @ DEVICE PIC16F88,WDT_OFF
    @ DEVICE PIC16F88,PWRT_ON
    @ DEVICE PIC16F88,MCLR_OFF
    @ 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 
    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
    
    OSCCON=%01111000 		'8 Mhz
    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
    
    DATAIN VAR BYTE[12]		'Define DATAIN as a byte array (12 Bytes)  
    
    loop: 				'Start of Communications Loop
    HSERIN [str DATAIN\12]		'Receive 12 bytes into array DATAIN
    HSEROUT [str DATAIN\12]		'Transmit 12 bytes from array DATAIN
    goto looP			'Goto Loop
    
    END
    Now what I want to do is use a qualifier so that the Hserin waits until $AA is received before it starts filling the array. I also want the $AA in the array though? Possible?

    So it should receive twelve bytes in all like this.

    0xAA,0x10,0x00,0x00,0x00,0x20,0x40,0x61,0x10,0x01, 0x00,0x74

    Does this look right?

    Code:
    loop: 				'Start of Communications Loop
    HSERIN [WAIT($AA), str DATAIN\12]		'Receive 12 bytes into array DATAIN  
    HSEROUT [str DATAIN\12]		'Transmit 12 bytes from array DATAIN
    goto looP			'Goto Loop
    I read that a delay may be required after the last send in the HSEROUT section or it may not transmit the last byte correctly?

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    You might want to get out of the habit of using the label LOOP: as ver 2.6 made loop a reserved word being used in the Do Loop routine.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by retepsnikrep View Post
    Now what I want to do is use a qualifier so that the Hserin waits until $AA is received before it starts filling the array. I also want the $AA in the array though? Possible?
    I don't think so but I haven't actually tested this. Add the timeout and test.

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 83
    Last Post: - 4th October 2021, 13:55
  2. PBP migration from 16F88 to 16F1827
    By RussMartin in forum mel PIC BASIC Pro
    Replies: 20
    Last Post: - 21st June 2010, 19:14
  3. PBP, ASM and LST files
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th January 2010, 14: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, 20:01
  5. Newby- PBP wont compile for 18F (MPLAB)
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th December 2005, 00: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