PIC18F25K22 USART

General discussion on mikroPascal PRO for PIC.
Post Reply
Author
Message
ismaelguamani
Posts: 1
Joined: 08 Mar 2018 07:55

PIC18F25K22 USART

#1 Post by ismaelguamani » 08 Mar 2018 08:03

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();
}

User avatar
petar.suknjaja
mikroElektronika team
Posts: 683
Joined: 05 Mar 2018 09:44
Location: Belgrade

Re: PIC18F25K22 USART

#2 Post by petar.suknjaja » 08 Mar 2018 19:16

Hi,

Unfortunately we do not support MPLAB software.

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

Regards,
Petar

Post Reply

Return to “mikroPascal PRO for PIC General”