bryanleo
LR44 Battery
Pogi/Ganda Points: 0
Offline
Posts: 4
|
 |
« on: September 27, 2008, 12:35:25 AM » |
|
Hi
How do you incorporate delay?
And how is the delay_milliseconds() used? <-- will this be enough?
The reason, I'm asking this is that my MCU is polling a multiplexer. I wanted to incorporate a delay so that it would read data slower so that I can transmit data slower as well.
Thanks, Bryan
|
|
|
|
|
Logged
|
|
|
|
|
The Philippine Electronics and Technology Forum
|
 |
« on: September 27, 2008, 12:35:25 AM » |
|
|
|
|
|
|
Logged
|
|
|
|
mArKhAo
Gas Turbine

Pogi/Ganda Points: 69
Offline
Gender: 
Posts: 2278
point and shoot
|
 |
« Reply #1 on: September 27, 2008, 12:36:57 AM » |
|
hehe. si sir.paranz ang makakasagot nyan. 
|
|
|
|
|
Logged
|
cut my heart out, for a souvenir....
|
|
|
|
The Philippine Electronics and Technology Forum
|
 |
« Reply #1 on: September 27, 2008, 12:36:57 AM » |
|
|
|
|
|
|
Logged
|
|
|
|
paranz
Moderator
Nuclear Reactor
   
Pogi/Ganda Points: 171
Offline
Gender: 
Posts: 4512
1/4W resistor specialist
|
 |
« Reply #2 on: September 27, 2008, 09:48:30 AM » |
|
you can use a software delay, which is not accurate. void delay(void) { int i; for(i=0;i<0xFFFF;i++) ; //do nothing } the problem above is that the exact amount delay is difficult to set (by trial and error?). Just try changing 0xFFFF to any value you deem acceptable Or you can use the Timer module (hardware-based delay) in the mcu. The 40-pin Z8 encore have 3 Timers, you can use one of these initialized in ONE-SHOT MODE. In ONE-SHOT mode, the Timer will overflow only once. This is an accurate hardware-based delay.
|
|
|
|
|
Logged
|
|
|
|
|
The Philippine Electronics and Technology Forum
|
 |
« Reply #2 on: September 27, 2008, 09:48:30 AM » |
|
|
|
|
|
|
Logged
|
|
|
|
bryanleo
LR44 Battery
Pogi/Ganda Points: 0
Offline
Posts: 4
|
 |
« Reply #3 on: September 27, 2008, 11:51:09 AM » |
|
Thanks a lot!  I will try this out later. By the way, what is the rough estimate in seconds of the delay of the 0xFFFF value? Can the delay be extended by adding another loop inside the for loop like.... void delay(void) { int i,j; for(i=0;i<=0xFFFF;i++) for(j=0;j<=0xFFFF;j++) ; //do nothing }
|
|
|
|
|
Logged
|
|
|
|
beginner wan
Diesel Generator
Pogi/Ganda Points: 46
Offline
Gender: 
Posts: 1454
Think Positive! Matutupad yang dream mo!
|
 |
« Reply #4 on: September 27, 2008, 12:11:39 PM » |
|
pwede po yan.. pero mas maganda ata kung tatawagin mo nalang yung delay function na dalawang beses.. like.. {..... delay(); delay(); ... } at least, pwede ka magdelay ng mas mabilis.. 
|
|
|
|
|
Logged
|
i;0.?QrEpM?4DEZZ]bkH{w@F<38.Jq@92Ds3KPQj60?EA7U\3M<A84J|AI.H R@>&?Ej,@;5H)o::7KE/:?QcXf?gX'39=,Z_Q[eYXc
|
|
|
paranz
Moderator
Nuclear Reactor
   
Pogi/Ganda Points: 171
Offline
Gender: 
Posts: 4512
1/4W resistor specialist
|
 |
« Reply #5 on: September 27, 2008, 01:01:18 PM » |
|
yup tama po kayong dalawa 
|
|
|
|
|
Logged
|
|
|
|
mochini77
Size AA Battery
  
Pogi/Ganda Points: 5
Offline
Gender: 
Posts: 136
The only thing that is permanent is change.
|
 |
« Reply #6 on: September 29, 2008, 02:51:15 PM » |
|
You can also try to use the sample code below to introduce a specific time delay in your application. Take note that it uses timer interrupt which depends on your clock frequency. You just need to call Delayms (x) where x is in milliseconds. e.i. Delayms (100); #include <ez8.h>
/* Function Prototypes and Definitions */ #define SET 1 #define RESET 0
void Init_Timer0(void ); void Delayms (unsigned int milliseconds);
unsigned char Millisecond_50=RESET; static unsigned int s_Ticks,s_Current_Milliseconds; /* Used by delayms() & isr_timer0() */
void Init_Timer0(void) { T0H = 0x00; /* Start value = 0 */ T0L = 0x00; T0RH = 0x4E; /* 1ms reload counter with 20MHz system clock */ T0RL = 0x00; T0CTL = 0x01; /* Continuous mode; clock divide by 1 */ IRQ0ENH |= 0x20; /* Timer 0 has normal priority */ IRQ0ENL |= 0x20; }
/* Interrupt service routine for Timer0 */ #pragma interrupt void isr_Timer0(void) { SET_VECTOR(TIMER0,isr_Timer0); s_Ticks++; /* at every 1ms increment counter */ if(s_Ticks==50) { Millisecond_50=SET; /* Set flag on 50ms timeout */ s_Ticks=0; /* Reset counter */ } s_Current_Milliseconds++ ; /* counter used for Delayms() funciton */ }
/* This function provides delay in milliseconds */ /* milliseconds Delay duration in milliseconds */ void Delayms (unsigned int milliseconds) { s_Current_Milliseconds = 0; T0CTL &= 0x7F; /* Disable Timer0 */ T0H = 0x00 ; /* Restart from 0 */ T0L = 0x00 ; T0CTL |= 0x80 ; /* Put On Timer0 */ while (s_Current_Milliseconds < milliseconds); /* wait till specified timeout occurs */ }
|
|
|
|
|
Logged
|
|
|
|
bryanleo
LR44 Battery
Pogi/Ganda Points: 0
Offline
Posts: 4
|
 |
« Reply #7 on: September 29, 2008, 07:42:12 PM » |
|
Salamat sa inyong lahat!  geleng
|
|
|
|
|
Logged
|
|
|
|
'yus
Technical People
Nuclear Reactor
   
Pogi/Ganda Points: 289
Offline
Gender: 
Posts: 4199
oops, kernel panic!
|
 |
« Reply #8 on: March 22, 2009, 07:11:04 PM » |
|
meron bang timer calculator for zilog? 
|
|
|
|
|
Logged
|
join PhilRobotics - Philippine Electronics and Robotics Enthusiasts Club
|
|
|
paranz
Moderator
Nuclear Reactor
   
Pogi/Ganda Points: 171
Offline
Gender: 
Posts: 4512
1/4W resistor specialist
|
 |
« Reply #9 on: March 22, 2009, 07:51:39 PM » |
|
^ wala. Hand calculation lang ang gamit for using hardware timers
|
|
|
|
|
Logged
|
|
|
|
|
SpongeBob
|
 |
« Reply #10 on: March 23, 2009, 12:01:17 PM » |
|
kung ano value ng reload at prescaler yun ang delay
Time-Out Period = (Reload Value x Prescaler Value) / System Clock Frequency (Hz)
|
|
|
|
|
Logged
|
|
|
|
'yus
Technical People
Nuclear Reactor
   
Pogi/Ganda Points: 289
Offline
Gender: 
Posts: 4199
oops, kernel panic!
|
 |
« Reply #11 on: April 08, 2009, 05:11:40 PM » |
|
galing sa "Z8 Encore XP F0823 Series Product Specification" Table 101. Oscillator Configuration and Selection Clock Source: Internal Precision RC Oscillator
Characteristics: • 32.8 kHz or 5.53 MHz • ± 4% accuracy when trimmed • No external components required • Unlock and write Oscillator Control
Required Setup: Register (OSCCTL) to enable and select oscillator at either 5.53 MHz or 32.8 kHz kanina ko lang nabasa.. 4% accuracy pala..  EDIT: magkaiba nga pala ang definition ng "Precision" saka ng "Accuracy"  hehe
|
|
|
|
|
Logged
|
join PhilRobotics - Philippine Electronics and Robotics Enthusiasts Club
|
|
|
piona
Hydroelectric
 
Pogi/Ganda Points: 118
Offline
Posts: 3072
earth - evils = heaven
|
 |
« Reply #12 on: April 08, 2009, 06:40:07 PM » |
|
yah tama ka Yus, +/-4% accurate siya sa designed freq, at stable naman ang freq niya......siguro sa range ng operating temp. niya
|
|
|
|
|
Logged
|
love without accomplishing the laws, is complicated - sshrekk
|
|
|
|
The Philippine Electronics and Technology Forum
|
|
|
|
|
|
Logged
|
|
|
|
|