avr-chat
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-chat] Trouble getting serial link with BlueSMiRF BT radio (used to


From: Rick Mann
Subject: [avr-chat] Trouble getting serial link with BlueSMiRF BT radio (used to work)
Date: Sun, 12 Mar 2006 03:49:30 -0800

I have a mega128-based board that uses USART0 to connect to a SparkFun BlueSMiRF radio. The BlueSMiRF effectively gives me a wireless serial connection; a serial port appears on my Mac, and I have ZTerm (or a custom Java app) connect to the serial port.

This has been working really well, up until recently. Now, if I attempt to connect, both programs report an error saying that the port is in use (by another app). I've disabled all serial-port related code in my firmware, and have narrowed the problem down to this: if I initialize USART0, my apps can't connect (the BlueTooth connection is made, but the subsequent serial link never establishes). If I do NOT initialize USART0, the connection is established just fine, and I can send AT commands to the BlueSMiRF.

FWIW, I've included my initialization code below. inCPUOsc is 16e6, inBaud is 76800.

void
USART0Init(UInt32 inCPUOsc, UInt32 inBaud)
{
        UInt32  baudConfig = (inCPUOsc / (inBaud * 16L)) - 1;
        
        UBRR0H = (uint8_t) (baudConfig >> 8);
        UBRR0L = (uint8_t) (baudConfig);

        // Enable receiver and transmitter; enable RX interrupt
// RX int enable TX int disable dtareg intdis RX enable TX enable 8-bit chars
        //                              1                               0       
                        0                               1                       
        1                               0
        
UCSR0B = (1 << RXCIE0) | (0 << TXCIE0) | (0 << UDRIE0) | (1 << RXEN0) | (1 << TXEN0) | (0 << UCSZ02);

// asynchronous --- no parity --- 1 stop bit --- 8-bit chars --- unused, write 0
        //                              0                               0       
                        0                               0                       
        1                               1                               0
        
UCSR0C = (0 << UMSEL0) | (0 << UPM01) | (0 << UPM00) | (0 << USBS0) | (1 << UCSZ01) | (1 << UCSZ00) | (0 << UCPOL0);
        
        //      Initialize the buffers…
        
        sSBReadPos = NULL;
        sSBWritePos = sSendBuffer;
        sSBAvailableWriteBytes = kSendBufferSize;
        sSBAvailableReadBytes = 0;
}

Any ideas?

TIA,

--
Rick






reply via email to

[Prev in Thread] Current Thread [Next in Thread]