| ??? 01/20/09 23:42 Read: times |
#161663 - Reply to Too Slow sampling Responding to: ???'s previous message |
Hi,
Perhaps the included code is a little better. The rest of the code is just an LCD driver but there are a few functions and variable declared extern. Why the extern intrptcnt you may ask. I was doing some experimenting with extern and left it with the lcd.h "extern volatile unsigned long intrptcnt;" The code was meant to do LcdWriteString(" Hello World") or LcdClear() on every fourth flash. What are you suggesting with the and operation? A bitwise and ??? Modulo was the only thing that came to mind. Can you suggest a better way to count 1000 ticks (roughly one second)???
#include <DS89C4xx.h>
#include "lcd.h"
#include "init8051.h"
sbit LED0 = P3^0;
sbit LED1 = P3^1;
sbit LED2 = P3^2;
sbit LED3 = P3^3;
sbit LED4 = P3^4;
sbit LED5 = P3^5;
sbit LED6 = P3^6;
sbit LED7 = P3^7;
volatile unsigned long count = 1000;
volatile unsigned char flash = 0;
intrptcnt = 0;
void Timer0_ISR (void) interrupt 1
{
ET0 = 0;
TF0 = 0; //clear flag
intrptcnt++;
TL0 = 0xCC;
TH0 = 0xD4;
ET0 = 1;
}
void main (void)
{
P0 = 0xFF; //turn off leds
initController();
delayMs(1000);
LcdInit();
while(1)
{
if (intrptcnt == count)
{
LED0 = ~LED0;
intrptcnt = 0;
flash++;
if (flash % 4 == 0)
{
LcdWriteString("Hello World");
if (flash == 100) flash = 0;
}
else
{
LcdClear();//clear
}
}
}
}
Cheers, Lee. |
| Topic | Author | Date |
| Program Conflict | 01/01/70 00:00 | |
| More info | 01/01/70 00:00 | |
| Reply to Per Westermark | 01/01/70 00:00 | |
| no code | 01/01/70 00:00 | |
| Reply to no code | 01/01/70 00:00 | |
| Too slow sampling | 01/01/70 00:00 | |
| Reply to Too Slow sampling | 01/01/70 00:00 | |
| Catch that magic marker | 01/01/70 00:00 | |
| Replay to Catch that magic marker | 01/01/70 00:00 | |
| Edison | 01/01/70 00:00 | |
Try this... | 01/01/70 00:00 |



