USART TXREG Problems


Closed Thread
Results 1 to 3 of 3
  1. #1
    BigH's Avatar
    BigH Guest

    Unhappy USART TXREG Problems

    Hi Its me again

    I am using Oshonsoft PIC Simulator IDE v5.33 to Monitor the Hardware UART for the Following Code. I only get an Output When I Execute the HSEROUT and I haven't a clue why this is, any Ideas Please

    DEFINE USART_TXSTA 20h
    DEFINE USART_RCSTA 90h
    DEFINE USART_BAUD 9600
    DEFINE USART_SPBRG 1

    REPEAT
    UNTIL PIR1.4 = 1
    TXREG = "A"

    REPEAT
    UNTIL PIR1.4 = 1
    TXREG = "B"

    REPEAT
    UNTIL PIR1.4 = 1
    TXREG = "C"

    REPEAT
    UNTIL PIR1.4 = 1

    ' HSEROUT ["D"] 'I Get NO Output at All Until I Include HSEROUT When I the Expected Output "ABCD"

    LOOP:
    NOOP
    GOTO LOOP

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898

    Default

    There's no USART_XXX define in PBP.

    you can even write..
    TXSTA=$20
    RCSTA=$90
    SPBRG=15
    this will do the same thing as
    DEFINE HSER_RCSTA 90h
    DEFINE HSER_TXSTA 20h
    DEFINE HSER_SPBRG 15 ' 9600 Bauds

    If you don't use HSERIN/HSEROUT you MUST write to the register directly as i already wrote in the example i post to you yesterday.

    Be sure of your SPBRG value... it's important and it's different for every crystal speed and baudrate. look the datasheet for that AND/OR use the calc i did in attachement.

    REPEAT
    UNTIL PIR1.4 = 1
    TXREG = "A"
    ??????

    Did you really look the example i posted before?
    Attached Files Attached Files
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    BigH's Avatar
    BigH Guest

    Talking Thanks

    Hi

    Its working, the confusion was caused by the DEFINE. Its seems with my compilier PICBasic PRO the TXSTA=$20 type expession works well but the DEFINE HSER_TXSTA 20h type expression Fails to Run but Compiles without Error. Looking back I can see that I had actually got it right but I chose to use DEFINE HSER_TXSTA 20h which I later change to DEFINE UART_TXSTA 20h in desperation/frustraction after seeing a reference of this type on the Web. Again thanks for getting me back on the rails. I am off to bed now and I will get the USART Interrupt working correctly in the morning.

    Regards Henry

Similar Threads

  1. My USART problems..
    By Glenn in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 31st July 2009, 01:00
  2. byte Tx w/ USART 16f876a problem
    By GargamelDigi in forum mel PIC BASIC
    Replies: 2
    Last Post: - 15th July 2008, 05:50
  3. problem with USART
    By leemin in forum Serial
    Replies: 4
    Last Post: - 11th December 2006, 17:56
  4. USART problems
    By egberttheone in forum mel PIC BASIC Pro
    Replies: 47
    Last Post: - 6th March 2005, 21:45
  5. Synchronous USART problems... HELP!!!
    By moni in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 14th November 2003, 19:00

Members who have read this thread : 1

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