It is currently 15 Oct 2018 20:44

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: PIC18F25K22 USART
PostPosted: 08 Mar 2018 08:03 
Offline

Joined: 08 Mar 2018 07:55
Posts: 1
Hi guys.

I am trying to do a serial comunication using Usart 1 with the pic 18f25k22, but i having a problem with the reception, the program doent toggle the reception interruption, if someone knows why , please hep me , could you take a look at the program and tell me what is the mistake, the transmition mode works good.

#include <stdio.h>
#include <stdlib.h>
#include <plib/usart.h>
#include "config.c" //configuration bits
#include<xc.h>
#include <plib/xlcd.h>
#include <plib/delays.h>

//CREATING VARIABLES
char Txdata1[] = "Bienvenido a la progrmacion del modulo \r\n";
char Txdata2[] = "espere mientras se configura el modulo.................. \r\n";
char Txdata3 ; //Variable Txdata3
char Txdata4[] = "\r\n Your has received.............. \r\n";
//char sim1[]="AT";
char sim1[]="AT+CPIN";
char a;
char b;
char c;
char d;
char e;


void main(void)
{
TRISA=0x00;

LATAbits.LATA0 = 1;
for (int x=0; x<=20; x++) __delay_ms(50); //Generate 500ms delay
LATAbits.LATA0 = 0;
for (int x=0; x<=20; x++) __delay_ms(50); //Generate 500ms delay
LATAbits.LATA0 = 1;

// OPEN USART1 PORT

Open1USART( USART_TX_INT_OFF &
USART_RX_INT_ON &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH &
USART_ADDEN_OFF,
52);


//INTERRUPTION CONFIGURATIONS PERIPHERAL AND GLOBALS

PIE1bits.RC1IE = 1; // active 1 interrupt RX
PIE1bits.TX1IE = 0; // desactive 0 interrupt RX
INTCONbits.GIE = 1; // active 1 peripheral interrupts
INTCONbits.PEIE = 1; // active 1 global interrupts
a=RCREG1;
b=RCREG1;
c=RCREG1;
d=RCREG1;
e=RCREG1;


// TRANSMITTER PIC TO PC

while(Busy1USART()); //Check if Usart is busy or not
puts1USART(Txdata1); //transmit the Txdata1("Initializing.................)
for (int x=0; x<=20; x++) __delay_ms(50); //Generate 500ms delay
while(Busy1USART()); //Check if Usart is busy or not
puts1USART(Txdata2); //transmit the Txdata2 (Hello.............)
for (int x=0; x<=20; x++) __delay_ms(90); //Generate 500ms delay
while(Busy1USART()); //Check if Usart is busy or not
puts1USART(sim1); //transmit
for (int x=0; x<=20; x++) __delay_ms(50); //Generate 500ms delay
while (1);
}

void interrupt Interrupcion()
{
// Receive data from PC to PIC

Txdata3 = Read1USART(); // Read the port Usart and save the value in Txdata3
while(Busy1USART());
puts1USART(Txdata4) ;
for (int x=0; x<=20; x++) __delay_ms(5); //Generate 500ms delay
while (Busy1USART());//Check if Usart is busy or not
Write1USART(Txdata3); //transmit the Txdata3("Initializing.....)
PIR1bits.RC1IF=0;
//LCDmain();
}


Top
 Profile  
 
 Post subject: Re: PIC18F25K22 USART
PostPosted: 08 Mar 2018 19:16 
Offline
User avatar

Joined: 05 Mar 2018 09:44
Posts: 411
Location: Belgrade
Hi,

Unfortunately we do not support MPLAB software.

You can check out UART examples written for our mikroC,mikroBasic or mikroPascal.

Regards,
Petar


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: