TAILIEUCHUNG - HandBooks Professional Java-C-Scrip-SQL part 184

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 184', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | void delay unsigned int nMilliseconds define CYCLES_PER_MS 260 Number of decrement-and-test cycles. unsigned long nCycles nMilliseconds CYCLES_PER_MS while nCycles-- delay The hardware-specific constant CYCLES_PER_MS represents the number of decrement-and-test cycles nCycles-- 0 that the processor can perform in a single millisecond. To determine this number I used trial and error. I made an approximate calculation I think it came out to around 200 then wrote the remainder of the program compiled it and ran it. The LED was indeed blinking but at a rate faster than 1 Hz. So I used my trusty stopwatch to make a series of small changes to CYCLES_PER_MS until the rate of blink was as close to 1 Hz as I cared to test. That s it That s all there is to the Blinking LED program. The three functions main toggleLed and delay do the whole job. If you want to port this program to some other embedded system you should read the documentation that came with your hardware rewrite toggleLed as necessary and change the value of CYCLES_PER_MS. Of course we do still need to talk about how to build and execute this program. We ll examine those topics in the next two chapters. But first I have a little something to say about infinite loops and their role in embedded systems. The Role of the Infinite Loop One of the most fundamental differences between programs developed for embedded systems and those written for other computer platforms is that the embedded programs almost always end with an infinite loop. Typically this loop surrounds a significant part of the program s functionality as it does in the Blinking LED program. The infinite loop is necessary because the embedded software s job is never done. It is intended to be run until either the world comes to an end or the board is reset whichever happens first. In addition most embedded systems have only one piece of software running on them. And although the hardware is important it is not a digital watch or a cellular phone or a

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.