usart in mikroc pro

Beta Testing discussion on mikroC PRO for PIC.
Post Reply
Author
Message
motahhir
Posts: 7
Joined: 02 Apr 2014 12:10

usart in mikroc pro

#1 Post by motahhir » 06 Apr 2014 23:50

Hi
i want to use usart library in mikroc pro but it isn't available !!

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: usart in mikroc pro

#2 Post by janni » 07 Apr 2014 11:49

Hardware USART library is available only for processors with appropriate hardware module. Did you check if the processor you chose has such a module?

motahhir
Posts: 7
Joined: 02 Apr 2014 12:10

Re: usart in mikroc pro

#3 Post by motahhir » 07 Apr 2014 15:03

thank you for your reply ofcourse i use a pic18F4580 but the library usart is not available in mikroc pro and i talk about usart not uart

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: usart in mikroc pro

#4 Post by janni » 08 Apr 2014 12:33

motahhir wrote:thank you for your reply ofcourse i use a pic18F4580 but the library usart is not available in mikroc pro and i talk about usart not uart
The hardware peripheral for this processor is actually called EUSART - which doesn't influence the name of the library available in mC PRO. The library is named UART uniformly for all processors with hardware serial communication module.

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: usart in mikroc pro

#5 Post by petar.timotijevic » 08 Apr 2014 14:57

Hello,

Please see

MikroC Pro UART Library
http://www.mikroe.com/download/eng/docu ... ibrary.htm


Best regards,
Peter

motahhir
Posts: 7
Joined: 02 Apr 2014 12:10

Re: usart in mikroc pro

#6 Post by motahhir » 08 Apr 2014 15:02

there is a difference between uart and USART !
uart: asynchronous
usart: synchronous

motahhir
Posts: 7
Joined: 02 Apr 2014 12:10

Re: usart in mikroc pro

#7 Post by motahhir » 08 Apr 2014 15:03

i talk about uart not usart !!

motahhir
Posts: 7
Joined: 02 Apr 2014 12:10

Re: usart in mikroc pro

#8 Post by motahhir » 08 Apr 2014 15:04

i talk about uart not usart !!

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: usart in mikroc pro

#9 Post by janni » 08 Apr 2014 16:48

motahhir wrote:there is a difference between uart and USART !
uart: asynchronous
usart: synchronous
Actually, USART means UNIVERSAL SYNCHRONOUS ASYNCHRONOUS RECEIVER TRANSMITTER, so it's not just for synchronous communication. If you have specifically asked for synchronous communication library, there'd be no misunderstanding.

UART library does work with USART (and EUSART) hardware modules but it's indeed dedicated to asynchronous communication.

motahhir
Posts: 7
Joined: 02 Apr 2014 12:10

Re: usart in mikroc pro

#10 Post by motahhir » 08 Apr 2014 17:01

I asked for synchronous communication library

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: usart in mikroc pro

#11 Post by janni » 08 Apr 2014 17:28

There's no such library built into mC. You'll have to write your own, I'm afraid.

User avatar
petar.timotijevic
mikroElektronika team
Posts: 1739
Joined: 19 Feb 2014 13:46
Location: Serbia
Contact:

Re: usart in mikroc pro

#12 Post by petar.timotijevic » 08 Apr 2014 18:45

Hello,

As Janni said you need to write your own library, also check www.libstock.com


Best regards,
Peter

motahhir
Posts: 7
Joined: 02 Apr 2014 12:10

Re: usart in mikroc pro

#13 Post by motahhir » 08 Apr 2014 22:34

thanks

x saber x
Posts: 3
Joined: 17 Jul 2014 18:29

Re: usart in mikroc pro

#14 Post by x saber x » 17 Jul 2014 23:32

hi,
to begin, i want to say that my level in english is average, so forgive me for the mistakes..
i am a beginner in C programming and this is the first time i work with mikroC.
so i want to write a code and i need your help ..
the code should do the following :

first : PORTB.f0=1

when i send the letter 'c'
i must receive the data that is on the port 'RA0'

when i send again the letter 'c'
i must receive the data that is on the port 'RA1'

when i send again the letter 'c'
i must receive the data that is on the port 'RA2'

when i send again the letter 'c'
i must receive the data that is on the port 'RA3'

when i send again the letter 'c'
i must receive the data that is on the port 'RA5'

when i send again the letter 'c'
i must receive the data that is on the port 'RE0'

PORTB.f0=0

when i send the letter 'c'
i must receive the data that is on the port 'RA0'

when i send again the letter 'c'
i must receive the data that is on the port 'RA1'

when i send again the letter 'c'
i must receive the data that is on the port 'RA2'

when i send again the letter 'c'
i must receive the data that is on the port 'RA3'

when i send again the letter 'c'
i must receive the data that is on the port 'RA5'

when i send again the letter 'c'
i must receive the data that is on the port 'RE0'

now the code should return to the beginning and expected that i send the letter 'c'
---

I actually have this code

Code: Select all

float rtdv, rtdr, temp,  y;
int msd, isd, i;
char temperature[6];
char uart_rd;

calcule()
{
rtdv=rtdv *5/1024;
rtdv=rtdv/5;
rtdr=rtdv*1000.0/(5.0-rtdv);
y=0.15274-(rtdr-100.0)*0.0002310;
if (y>=0)y = sqrt(y);
temp = (y-0.39083)/(-0.0001155);
bytetostr(temp,temperature);

delay_ms(1);
}

affichage() 
{
UART1_Write_Text(temperature);
strcpy(temperature,"");
}

void main()
{

TRISA = 0xFF;  
TRISE = 0xFF;
TRISB = 0x00;  

PORTB = 1;      

UART1_Init(9600);

while(1)                             
{       portb.f1=1;
        if (UART1_data_ready())
         {
                  uart_rd = UART1_read();
                  if(uart_rd=='c')           
                  {
                        PORTB.f0=1;        

                        for (i=0; i<6 ;i++)
                        {
                         delay_ms(5);          
                         rtdv=adc_read(i);
                         UART1_Write(13);        
                         calcule();              
                         affichage();         
                         }

                        PORTB.f0=~portb.f0;      
                        
                        for (i=0; i<6; i++)
                        {
                         delay_ms(5);
                         rtdv=adc_read(i);
                         UART1_Write(13);        
                         calcule();             
                         affichage();       
                         }
                 }
         }
}
}
but it does not satisfy my need..
in this code, when i sent the letter 'c' i receive all data contained on ports..

could you help me modify this code or write one that works according to algorthme above?

Post Reply

Return to “mikroC PRO for PIC Beta Testing”