Menu

Help with no serial output

Help
2010-04-08
2013-05-30
  • Nobody/Anonymous

    here is my test program:
    #chip 16F767, 12 'mhz
    #config MCLRE=off, WDT=off
    lcdcon = 0
    dir portc.7 in  'serial in
    dir portc.6 out  'serial out
    #define USART_BLOCKING
    #define USART_BAUD_RATE 9600 'the speed you want
    InitUsart
    On Interrupt UsartRX1Ready call rec_data
    dim temp as byte
    dir portc.0 out  'opener

    Start:
    set portc.0 on
    wait 1 s
    set portc.0 off
    wait 1 s
    goto start

    sub rec_data

    If RCIF On Then
    HSerReceive NewDataIn
    temp = newdatain
    if temp = 48 then display_data
    end if
    end sub

    sub display_data
    Transmitserial(49)
    end sub

    sub TransmitSerial_Print(PrintData$)
    PrintLen = PrintData(0)
    if PrintLen = 0 then exit sub
    'Write Data
    for SysPrintTemp = 1 to PrintLen
    transmitSerial(PrintData(SysPrintTemp))
    next
    end sub

    sub TransmitSerial(xmitdata)
    LoopTransmit:
    IF PIR1.TXIF OFF THEN goto LoopTransmit 'check if transmitter is busy
    TXDATA = xmitdata
      ' CalcParity(TXDATA) 'calculate parity
      ' rotate ParityByte RIGHT 'get parity bit into status.c
      ' SET TXSTA.TX9D OFF 'set parity bit to zero
      ' IF STATUS.C = 1 THEN SET TXSTA.TX9D ON 'if status.c is one, set parity bit
    TXREG = TXDATA 'transmit data
    end sub

    it runs the main fine until i send it the "0" and then it just stops running the main and does nothing with no output on the serial?
    why

     
  • Nobody/Anonymous

    in the "lowlevel"  library GCBASIC>include>lowlevel>usart.h  i'll bet the "blocking" statement is backwards.  It was when I was using the usart a few weeks ago.

    Search the forums.  there are a couple fixes to the usart.h

     
  • mmotte

    mmotte - 2010-04-08

    in usart.h
    Find

    code
    sub HSerSend(In SerData)

    #ifdef PIC

    #ifdef USART_BLOCKING

    Wait While TXIF = Off

    #endif

    TXREG = SerData

    #endif

    #ifdef AVR

    #ifdef USART_BLOCKING

    Wait While UDRE = Off

    #endif

    UDR = SerData

    #endif

    end sub
    code/

    I bet "Wait While TXIF = Off"   will say "=On"

    73
    m

     
  • Nobody/Anonymous

    thanks

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.