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.

dsPIC30F6010A- Controller Regarding

Status
Not open for further replies.

Prabakaran

Full Member level 3
Joined
Jan 22, 2007
Messages
167
Helped
9
Reputation
18
Reaction score
3
Trophy points
1,298
Location
Chennai(India)
Activity points
2,273
u2txreg

Hello,
I m using dsPIC30F6010A controller in which i can send the data to serial port but when i m configuring as a interrupt to receive a single character from serial port . I am not able to receive the data from serial port .Please find the code below and say any corrections to be done.


This is my Code.
#include <p30f6010A.h>

#define BUTTON1 !PORTGbits.RG6 //S4 on PCB
#define BUTTON2 !PORTGbits.RG7 //S5 on PCB
#define BUTTON3 !PORTGbits.RG8 //S6 on PCB
#define BUTTON4 !PORTGbits.RG9 //S7 on PCB

#define RS485_TX PORTFbits.RF5// Tx pin
#define RS485_RX PORTFbits.RF4 // rx pin

// This the RS485_TXENA (active high line)
#define RS485_TXENA LATGbits.LATG1
// This the RS485_RXENA (active LOW line)
#define RS485_RXENA !LATGbits.LATG0

void delay1( long t);
void Init(void);
void Delay(unsigned long count);
void serial_send(char *str1);
void __attribute__((__interrupt__)) _T1Interrupt(void);
long timer1cnt = 0;
char timer_bit;
unsigned int value=65;
/******************************
* Configuration Bits
******************************/
//_FOSC(CSW_FSCM_OFF & FRC_PLL8); /* Fast RC with PLLx8 = 16MIP Clock Mon/Switch OFF */
//_FOSC(CSW_FSCM_OFF & XT_PLL8); /* 8MHz Crystal with PLLx8 = 16 MIP */
//_FWDT(WDT_OFF); /* Watch dog Timer OFF */
//_FBORPOR(PBOR_OFF & MCLR_EN); /* Brown Out OFF, MCLR Enabled */
//_FGS(CODE_PROT_OFF); /* Code Protect OFF */

int main(void)
{

Init();
while(1)
{
if(U2STAbits.URXDA)
U2TXREG = 65;
ClrWdt();
}

return(0);
}

void delay1( long t)
{
int j;
long i;
for(j=0;j<10;j++)
{
for(i=0;i<t;i++)
;
ClrWdt();
}

}
void Delay(unsigned long count)
{
unsigned int j;

for(j=0;j<count;j++)
ClrWdt();

}

void serial_send(char *str1)
{

while(*str1 !=0)
{
while(U2STAbits.UTXBF==1); /* Wait until TX buf read for new data */
U2TXREG=*str1;
str1++;
//delay1(10000);
}
}


void Init()
{
//OSCCON=0x3300; /* Select Primary Oscillator */
/* Set up I/O Port */
ADPCFG=0xFFFF; /* Analog ports as Digital I/O */

U2BRG=96; /* 9600Baud for 16MIP (See FRM Tables) */
U2MODE=0x8000; /* Enable, 8data, no parity, 1 stop */
U2STA =0x8400; /* Enable TX */


TRISB=0x0000; /* Port B output Data as well as serial port */
LATB=0x0000; /* Initial Value of 0 */

// Configuring the switch as Input
TRISG = 0xFFFF;
LATG = 0x0000;

TRISF = 0xFFFF;
LATF = 0x0000;

///IFS1bits.U2RXIF = 1; //Clear UART Rx interrupt flg
IFS1bits.U2RXIF = 1;
IEC1bits.U2RXIE = 1; //Enable UART Rx receive interrupt
IPC6bits.U2RXIP = 3;

TRISA = 0x39FF;
PORTA = 0x8000;
delay1(100000);

PORTA = 0x4000;
delay1(100000); //4805

PORTA = 0x0400;
delay1(100000);

PORTA = 0x0200;
delay1(100000); //2400 - 56 2500 - 28

PORTA = 0;


}

void __attribute__((__interrupt__)) _T1Interrupt(void)
{
while(U2STAbits.UTXBF==1);
U2TXREG = 50;
IFS0bits.U1TXIF = 0;
}

void __attribute__((__interrupt__))_U2RXInterrupt(void)
{
while(U2STAbits.URXDA) //If Rx FIFO buffer has data
{
while(U2STAbits.UTXBF); //Wait if Transmit buffer is full
U2TXREG = U2RXREG; //Echo received char
}
IFS1bits.U2RXIF = 0; //Clr UART_Rx interrupt flag
}

void timer1_init(void)
{
T1CON = 0x8040;
// IFS0bits.T1IF = 0;
IEC0bits.T1IE = 1;
TMR1 = 0;
PR1 = 2000;
}




Thanks
M.Prabakaran
 

set up timer dspic30f6010a

Dear all.

Those who worked in DSPIC 30 Series can help us. Or Send me the C30 Complier Help File to Understand the Keyword used in MICROCHIP Processor for Specific DSPIC30f Series.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top