Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help needed with uart for dsPIC33FJ128MC802

Status
Not open for further replies.

seone

Newbie level 1
Joined
Feb 20, 2006
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,297
Help!

Hi!
I'm trying uart for dsPIC33FJ128MC802. I have the following ports and UART initialize. But i'dont know which pin is U1TX. Can you say me how to initialize pin for UART1 and UART2 and which pins U1RX,U1TX,U2RX,U2TX.

/******************************Include*******************************/
#include <htc.h>
#include <dspic.h>
#include <dspic33fj128mc802.h>
#include "delay.h"
/*******************************Config*******************************/
__CONFIG(FGS, GCPP);
__CONFIG(FOSCSEL, IESODIS & TEMPDIS & OSC);
__CONFIG(FOSC, FCKSMDIS & OSC2DIO & POSCHS);
__CONFIG(FWDT, WDTDIS);
__CONFIG(FPOR, PWRTDIS);
/******************************Variable******************************/
#define FCY 40000000
#define BAUDRATE 115200
#define BRGVAL ((FCY/BAUDRATE)/16)-1
/***************************Port Initialize**************************/
void InitPorts(void)
{
AD1PCFGL=0xFFFF;
TRISA=0x0000;
PORTA=0x0000;
LATA =0x0000;
TRISB=0x0000;
PORTB=0x0000;
LATB =0x0000;
}
/*************************Property Initialize************************/
void InitUART1(void)
{
U1MODEbits.ABAUD = 0; // Bit5 No Autobaud
U1MODEbits.BRGH = 1; // Bit3 High Speed
U1MODEbits.PDSEL = 0; // Bit1 No Parity, 8 Data Bit
U1MODEbits.STSEL = 0; // Bit0 One Stop Bit
U1BRG = BRGVAL; // Baud Rate Generator Prescaler
U1MODEbits.UARTEN = 1; // Bit15 Enable UART1
U1STAbits.UTXEN = 1; // Enable UART1 Tx
}
/****************************Main Function***************************/
void main(void)
{
InitPorts();
InitUART1();
while (1)
{
PORTBbits.RB13=1;
DelayMs(500);
PORTBbits.RB13=0;
DelayMs(500);
U1TXREG = 'a';
}
}
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top