byte Tx w/ USART 16f876a problem


Closed Thread
Results 1 to 3 of 3
  1. #1

    Default byte Tx w/ USART 16f876a problem

    Ok I searched through this site and can't find a solid answer. I did find a lot of usefull info to get me to this point though.

    I am gettign an output but is just not the byte I try to send. The PWREN# bit is coming from a FT232R chip from FTDI which is a USB bridge.

    I am using picbasic, and the code is:

    Symbol TRISA = $85
    Symbol PORTA = $05
    Symbol TRISB = $86
    Symbol PORTB = $06
    Symbol TRISC = $87
    Symbol PORTC = $07
    Symbol ADCON1 = $9F ' A/D Control Register 1
    Symbol ADCON0 = $1F ' A/D Control Register 0

    ' Define the USART registers
    Symbol PIR1 = $0C ' Peripheral Interrupt Flag register
    Symbol RCSTA = $18 ' Receive Status and Control register
    Symbol TXREG = $19 ' Transmit Data register
    Symbol RCREG = $1A ' Receive Data register
    Symbol TXSTA = $98 ' Transmit Status and Control register
    Symbol SPBRG = $99 ' Baud Rate Generator register

    init:

    Poke ADCON1, 6 ' Set all PortA to digital I/O
    Poke ADCON0, 5 ' Set all PortB to digital I/O
    Poke TRISB, %00000000
    Poke TRISA, %11111111 ' sets "1" to input,"0" output

    ' Initialize USART
    Poke TRISC, %10111111 ' Set TX (PortC.6) to out, rest in
    Poke SPBRG, 25 ' Set baud rate to 9600 (4MHz clock)
    Poke RCSTA, %10010000 ' Enable serial port and continuous receive
    Poke TXSTA, %00100000 ' Enable transmit and asynchronous mode


    usart:

    Peek PORTA, b0
    IF bit0 = 0 Then main ' usb PWREN# bit

    GoTo usart

    main:

    Poke PORTB, %01000000

    Peek PORTA, b0
    IF bit1 = 0 Then tx ' when button is pressed Tx one byte

    GoTo main



    tx:

    b0 = 0

    Peek PIR1, b0
    IF bit4 = 0 Then tx

    Poke TXREG, $7A ' byte to send over Tx

    Poke PORTB, %01110000 ' flash two LED's when Tx
    Pause 300
    Poke PORTB, %01000000

    GoTo main


    Any help will be very appreciated! Been stuck on this all day!

    Thank you in advanced

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Are you 100% sure about those ADCON register settings?
    How about the Comparator Module register settings?

  3. #3


    Did you find this post helpful? Yes | No

    Default

    from some other help I received Poke ADCON0 should not be neccessary.

    Poke ADCON1 in the data sheet says 011x for all pins, so this equals 6 or 7 with the x.

    I have no problem reading the port a or port b, I just can't get anything to be sent out the USART Tx. When I send (or try to) the LED's flash with the button push just no data goes over Tx. The scope shows a constant 5v.

    Thanks,
    Jeremy

Similar Threads

  1. Problem with 16Ff648a
    By aerostar in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 12th November 2009, 18:15
  2. LCD freeze
    By harryweb in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 5th October 2009, 08:01
  3. byte compression
    By Norbert in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 16th June 2007, 18:04
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. 16F877 RAM Question
    By Art in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 6th August 2005, 11:47

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