delay

General discussion on mikroC.
Post Reply
Author
Message
nav
Posts: 7
Joined: 03 Jun 2011 02:48

delay

#1 Post by nav » 03 Jun 2011 09:45

i need to modify the delay_ms function to cheack a port change during the delay time period. how can i make this

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: delay

#2 Post by tihomir.losic » 03 Jun 2011 09:53

Hello,

Our source codes are not open source and they are not available for viewing or editing.
Our libraries come with our compilers in compiled form (source code hidden).
We decided to do this because if we allow our costumers to change source codes we would not be able to provide technical support for it.

You can, however, search throughout Forum where some pieces of our libraries are posted for viewing, so you could maybe find what you are looking for.

Best regards,

Losic Tihomir
mikroElektronika [Support team]

nav
Posts: 7
Joined: 03 Jun 2011 02:48

Re: delay

#3 Post by nav » 03 Jun 2011 10:51

Thank you.
how can i include ASSEMBLY code between C codes

User avatar
tihomir.losic
mikroElektronika team
Posts: 2138
Joined: 02 Dec 2009 14:16
Location: Serbia
Contact:

Re: delay

#4 Post by tihomir.losic » 03 Jun 2011 10:54

asm.PNG
asm.PNG (41.19 KiB) Viewed 2583 times
Best regards,

Losic Tihomir
mikroElektronika [Support team]

nav
Posts: 7
Joined: 03 Jun 2011 02:48

Re: delay

#5 Post by nav » 03 Jun 2011 11:04

thank you

void main() {
TRISA=0;

PORTB=0;
do{
if(PORTB.F2==1){
Delay_ms(1500);
if(PORTB.F2==1){
PORTA.F1=1;
}else {
PORTA.F1=0;
}
}while(1);
}

in the above coding i need to make PORTA.F1=0 if PORB.F2=0 during the delay time
please good enough to help me.

Sparky1039
Posts: 1179
Joined: 24 Nov 2005 20:07
Location: Colorado, USA

Re: delay

#6 Post by Sparky1039 » 03 Jun 2011 18:08

Use one of the many timers on the PIC instead of the compiler to generate the delay. This will allow you to monitor the port pin for change all the while the timer is working in the background. Using the compiler delay is considered a "blocking" function whereby all of the PIC's resources are focused on performing this task and nothing else.

Muphy
Posts: 318
Joined: 24 Feb 2008 14:05
Location: Stonehaven Scotland

Re: delay

#7 Post by Muphy » 03 Jun 2011 21:10

If you need to test changes with PORTB pins then on many chips there is an interrupt that you can use and the interrupt will work regardless of if you are in a delay or not.

Look up the datasheet for your PIC for "Interrupt On Change"


M

Post Reply

Return to “mikroC General”