• AVR Freaks

LockedSerial reception not working

Author
ambo
New Member
  • Total Posts : 14
  • Reward points : 0
  • Joined: 2012/04/12 17:37:08
  • Location: 0
  • Status: offline
2012/04/20 16:28:21 (permalink)
0

Serial reception not working

I'm using a PIC18F46K22 revision A2.  Following the erratta, I set BRGH= 1 and BRG16 =1 and running the uart at 9600bps.
Transmitting data is fine.  However, receiving data does not seem to work.  Any ideas or is there a problem in my code?  Its not working for both USART1 and USART2. 
 
 #include <xc.h>   #ifndef _XTAL_FREQ 
#define _XTAL_FREQ  64000000
#endif   #pragma config FOSC=HSMP, FCMEN=OFF, IESO=OFF, PLLCFG=ON, PRICLKEN=ON
#pragma config PWRTEN=OFF, WDTEN=OFF, BOREN=OFF
#pragma config MCLRE=EXTMCLR, HFOFST=ON
#pragma config LVP=OFF
#pragma config CP0=OFF, CP1=OFF, CP2=OFF, CP3=OFF, CPB=OFF, CPD=OFF
#pragma config WRTC=OFF, WRTB=OFF, WRTD=OFF, WRT0=OFF, WRT1=OFF, WRT2=OFF, WRT3=OFF
#pragma config EBTR0=OFF, EBTR1=OFF, EBTR2=OFF, EBTR3=OFF, EBTRB=OFF   void main()
{
    baud1USART( BAUD_IDLE_CLK_LOW & BAUD_16_BIT_RATE & BAUD_WAKEUP_OFF &
                BAUD_AUTO_OFF );
    Open1USART( USART_TX_INT_OFF & USART_RX_INT_OFF &  USART_ASYNCH_MODE &
                USART_EIGHT_BIT & USART_CONT_RX & USART_BRGH_HIGH, 1666 );
   
    while (1)
    {
        putc1USART(getc1USART());
    }
}  

 
Edit:
Got it working now  ....  I forgot to disable the ADC port!
post edited by ambo - 2012/04/20 21:59:30
#1

5 Replies Related Threads

    DarioG
    Allmächtig.
    • Total Posts : 54081
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: Oesterreich
    • Status: offline
    Re:Serial reception not working 2012/04/21 01:58:52 (permalink)
    0
    ok Smile

    GENOVA :D :D ! GODO
    #2
    charan s
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2013/01/30 00:59:12
    • Location: 0
    • Status: offline
    Re:Serial reception not working 2013/01/30 01:13:08 (permalink)
    0
    ambo,
     
          I am  also using  pic18f46k22  ,  uart 1 is working fine for me .  but  uart 2  doesn,t seems to work for me  .  I am unable to send data using uart2 module.
          can  u please check that  and inform  me whether  uart2  works for me
    #3
    Fantalucio
    Starting Member
    • Total Posts : 60
    • Reward points : 0
    • Joined: 2003/11/07 12:44:52
    • Location: Verona - ITALY
    • Status: offline
    Re:Serial reception not working 2013/01/30 08:05:52 (permalink)
    0
    Hi charan,
    in 18f46k22 addresses F38h through F5Fh, are also used by SFRs, but are not part of the Access RAM. Users must always use the complete address, or load the proper BSR value, to access these registers.
     
    Ciao,
    Lucio
     


    #4
    charan s
    New Member
    • Total Posts : 10
    • Reward points : 0
    • Joined: 2013/01/30 00:59:12
    • Location: 0
    • Status: offline
    Re:Serial reception not working 2013/01/30 10:21:36 (permalink)
    0
    I am coding in c using c18 compiler, so how can I take care of
    BSR register. I am thinking compiler has to take care of it.
    #5
    Fantalucio
    Starting Member
    • Total Posts : 60
    • Reward points : 0
    • Joined: 2003/11/07 12:44:52
    • Location: Verona - ITALY
    • Status: offline
    Re:Serial reception not working 2013/01/31 01:38:00 (permalink)
    0
    I had some trouble with 18f86k22 for this issue, but only in assembly, not with XC8.
    I have no experience with the C18.
    Try disabling the other modules that share the uart2 pins.


    Ciao!
    Lucio
    post edited by Fantalucio - 2013/01/31 01:43:31
    #6
    Jump to:
    © 2020 APG vNext Commercial Version 4.5