Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/15/09 21:27
Read: times


 
#164635 - BRG set as part of UART Init (before EA)
Responding to: ???'s previous message
Ports are configured first,(so that individual init functions for I2C, ADC, UART, can reconfigure the ports as they want them.

After all inits are completed EA is enabled

Here is the init code for the UART. nothing out of the ordinary I would think, most of this as per Code Architect (I think - it has been a while since I looked at what it generates)


Regards

Marshall
void uart_init(void){

    //turn on UART
    PCONA &= ~0x02;
    // configure UART
    // clear SMOD0
    PCON &= ~0x40;
    SCON = 0x50;

    // set or clear SMOD1
    PCON &= 0x7f;
    PCON |= (0 << 8);
    SSTAT = 0xE0;  //enable double buffering for a bit more resiliency

    // enable break detect
    //AUXR1 |= 0x40;

    // configure baud rate generator
    BRGCON = 0x00;

   //set speed (19200)
   BRGR0 = 0x70;
   BRGR1 = 0x01;



    BRGCON = 0x03;

    // TxD = push-pull, RxD = input
    P1M1 &= ~0x01;
    P1M2 |= 0x01;
    P1M1 |= 0x02;
    P1M2 &= ~0x02;




   // Setup ring buffers.
    s_rxRingEmpty = 1;
    s_txRingEmpty = 1;
    s_rxWrIdx     = 0;
    s_rxRdIdx     = 0;
    s_txWrIdx     = 0;
    s_txRdIdx     = 0;

    // set receive isr priority to 0
    IP0 &= 0xEF;
    IP0H &= 0xEF;

    IP0 |= 0x10;
    IP0H |= 0x10;



    // enable uart receive interrupt
    ESR = 1;


    //set tx priority to high
    IP1 |= 0x40;
    IP1H |= 0x40;


    // enable uart transmit interrupt
    EST = 1;

    //clear any Flags that may have been set during init.
    RI = 0;
    TI = 0;



}


List of 20 messages in thread
TopicAuthorDate
RI always set after EA Set            01/01/70 00:00      
   I don't know, but...            01/01/70 00:00      
      your application should be designed so as to be tolerant            01/01/70 00:00      
   Check if the Rx pin is pulled low?            01/01/70 00:00      
      Ports are set as:            01/01/70 00:00      
         without looking at the datasheet, I can say it is wrong            01/01/70 00:00      
            Why?            01/01/70 00:00      
               I did not clean my glasses            01/01/70 00:00      
                  Config Registers            01/01/70 00:00      
         Check the BR and FE bits in SSTAT.            01/01/70 00:00      
            Yes they are set - Why?            01/01/70 00:00      
   When do you start the BRG?            01/01/70 00:00      
      BRG set as part of UART Init (before EA)            01/01/70 00:00      
         I would...            01/01/70 00:00      
            Thanks - Done            01/01/70 00:00      
   aren't the LPC9xx's pins...            01/01/70 00:00      
      Yes but - it also happens in the real hardware            01/01/70 00:00      
         the point of asking nonsense questions...            01/01/70 00:00      
            Understood, appreciate being 2nd guessed            01/01/70 00:00      
               The Teddy Bear Effect            01/01/70 00:00      

Back to Subject List