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.

[PIC] Problem with delay in dsPIC30F5011

Status
Not open for further replies.

saikiran@ees

Member level 3
Joined
Oct 2, 2015
Messages
58
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Location
Hyderabad
Activity points
455
Hi everybody

My problem is too much delay in my program even i entered the required condition.In below i posted the function that is using for updating the Digital Clock and i am not using interrupt.In below function i wrote some delay for taking the values from buffer and after that if i pressed entered it will show the updated clock or error without taking single second delay.But if reduce the delay the values will not read properly from buffer and when i pressed entered it taking 10 seconds delay for producing output.


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
void update_time()
{
    unsigned long int y=0,j=0;
    unsigned char hour,minute,second,temp_Buff[9];
    unsigned char i=0,k,hh1,hh2,mm1,mm2,ss1,ss2;
    if(flag==1)
        printf("\nTime %02d:%02d:%02d", hr,min,sec);
        flag=0;
   
    if( U1RXREG == 'Y')
    { 
        printf("\nEnter Hours,Minutes and Seconds like HH:MM:SS");
      
     do
   {    for(i=0;i<9;i++)
        {
            temp_Buff[i] = U1RXREG;
              for(y=0; y<65000; y++)
                for(j=0;j<=10;j++)
                 Nop();
               
        }      
            
                hh1=temp_Buff[1]-48;           
                hh2=temp_Buff[2]-48;
                mm1=temp_Buff[4]-48;
                mm2=temp_Buff[5]-48;
                ss1=temp_Buff[7]-48;
                ss2=temp_Buff[8]-48;
                hour=(hh1*10)+hh2;
                minute=(mm1*10)+mm2;
                second=(ss1*10)+ss2;
        }  
         
       while(U1RXREG ==13);   
        
            if(hour>23)
                printf("\nHour is not in range");
                else
                    hr=hour;
            
            if(minute>59)
                printf("\nMinute is not in range");
                else
                    min=minute;
        
            if(second>59)
                printf("\nSecond is not in range");
                else
                   sec=second;
          
      }  
            
       
       U1STAbits.OERR=0;          
}





Thank You.
 
Last edited by a moderator:

That is not the way to input characters through the UART.
You cannot simply wait for a period of time and then grab whatever happens to be in the buffer.
If you don't want to use interrupts (and I imagine that you are just learning how to do this and so I recommend that you don't use interrupt yet) simply wait for the URXDA bit to be set and then read the value in the UART buffer. You can then check to see if it is the terminator you are waiting for and either loop back for the next character or break out to process the received characters.
Susan
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top