Page 29 - PIC18F4550微處理機C語言設計實務
P. 29

૵ሔଡ଼ΥႧԊձ C ႧԊ 1




                 const:

                       ίᜊᅰΤ၈ۃࠦᅺͪ constdԨٜટረʚ੬ᅰ࠽f߰ᜊᅰ܁ѓމ੬ᅰdۆڌͪϤᅰ
                 މʔ̙஗һҷdᇜᙇኜۆึਗ਼Ϥᜊᅰᓖ׳ί೻όাኳ᜗ٙЗໄʕdν؈ᇜᙇኜ೯ତϞ

                 ɛΆྡᜊһdึ೯̈ᙆѓৃࢹf
                 Էνj


                   const unsigned char Var1 = 123;  //  Var1 ܁ѓމ੬ᅰ 123
                   Var1 = 0;                        // Άྡᜊһ੬ᅰ Var1 ۆᇜᙇኜึ೯̈ᙆѓ

                 volatile:

                       ΪᏐᇜᙇኜत׌d߰ᜊᅰ܁ѓމϤdۆڌͪϤᜊᅰ࠽ᎇ̙ࣛঐ஗ҷᜊdϾ˲ᇜᙇ
                 ழ᜗߰ආБ௰Գʷࣛdɰʔึਗ਼ϤᜊᅰٙהϞਗЪ՟ऊfɓছԴ͜ volatile ڌͪމ೷᜗

                 մᗙٙᅲπኜ€Timer, UARTneא٫݊ᅲπኜึΪމ̮௅፩ɝϾҷᜊ€PORTe
                 א݊ίʕᓙՌό༁ࠦהԴٙ͜ᜊᅰeᒔ݊ʔซ஗௰Գʷࡌҷٙᜊᅰf

                 Էνj


                   static volatile unsigned char PORTA  @ 0x05;

                       ڌͪ PORTA வࡈЗ׵ 0x05 Зѧٙᜊᅰd̙ঐᎇࣛΪމՉ˼Ϊ९ҷᜊՉʫ࢙fԷ
                 νᛘ՟ PORTA ٙ࠽ܝdટഹࠅԱኽ༈࠽̘ਂкᓙϾӔ֛ʱ҉ٙਗЪࣛdᇜᙇኜ੬ึ

                 މə௰Գʷdఱ̥ᛘɓϣ PORTA ܝdఱɓٜਂ৙ਸ਼кᓙdӚΎ̘ࠠᛘ PORTAdԴ੻
                 ௘ɝೌᇊ৙ਸ਼f܁ѓމ volatile ࣛdᇜᙇኜʔึމəಯˇ೻όڗܓϾ޲̘ਂࠠልᛘ՟
                 PORTA ٙਗЪf


                 presistent:

                       ߰ᜊᅰ܁ѓމϤdۆڌͪϤᜊᅰί MCU ක֐઼ਗࣛʫ࢙Ԩʔึ஗૶ৰdϾ˲Ϥ
                 ᜊᅰึၾՉ˼ᜊᅰπ׳ίʔΝٙাኳ᜗Зໄf

                 Էνj

                   persistent long reset_count;


                       ڌͪ reset_count வࡈᜊᅰԨʔึΪމ MCU ࠠอ઼ਗࣛϾ஗૶ৰމཧdה˸̙˸
                 ί೻όක֐ଢ଼̋ϤᜊᅰϾ੻ٝࠠอ઼ਗٙϣᅰf








                                                                                                             19
   24   25   26   27   28   29   30   31   32   33   34