| The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers. |
AN1853 Freescale Semiconductor, Inc. Embedding Microcontroll
Top Searches for this datasheetOrder this document AN1853/D AN1853 Freescale Semiconductor, Inc. Embedding Microcontrollers Domestic Refrigeration Appliances William Mackay Motorola Microcontroller Division East Kilbride, Scotland. Introduction This Application Note describes demonstrates extensive capabilities another comprehensive economic Microcontroller from Motorola 68HC08 portfolio. device HC908KX8, very cost, high performance 16-pin flash device with user selectable Internal Oscillator on-board Reset Circuitry. This document details HC908KX8 controls domestic fridge appliance implements control Fridge Compressor Induction Motor based temperature measurement, including some energy cost saving features. microcontroller associated application hardware have been developed embedded Fridge appliance, with application code written `C'. Embedding Motorola Microcontroller into domestic appliance numerous advantages, both through development life cycle production environment. common hardware software development platform established which support range appliances present potential future needs. programmability device provides flexible software development environment that accommodates low-end through mid-range appliance model software versions, flash user space allows future application functionality enhancements, along with additional time saving development advantages re-programmable flash technology. These attributes increase convenience planning future appliance developments, terms Motorola, Inc., 1999 More Information This Product, www.freescale.com AN1853 Freescale Semiconductor, Inc. Application Note hardware, standardisation Printed Circuit Board design manufacturing practices achieved with less risk lower component count than discrete Application Specific Integrated Circuit solutions. short, development time reduced, production costs minimised time-to-market place reduced significantly with better product flexibility reliability. Domestic appliances subjects strict European regulations, with similar constraints imposed USA. These regulations result demanding operational constraints Refrigeration appliances. Predominately, challenge improve energy efficiency electromagnetic compatibility (EMC), enhance marketable features appliance. internal oscillator on-board reset circuit features make improved performance better reliability electrically noisy environments. With these enhancements, flash programmability, adaptable feature set, Motorola continue strive meet global industry challenges with leading system solutions. Freescale Semiconductor, Inc. Basic Refrigeration main electrical components required domestic refrigeration system some means temperature control Refrigerant Compressor. Embedded within domestic Fridge compartment Evaporator, outside Condenser, heat exchanging coils refrigerant compressor. compressor driven electrical motor. When power applied compressor pressure refrigerant increased. This increase pressure causes increase refrigerant temperature heat produced this action dissipated through heat exchanging coils rear appliance. This action illustrated following diagram. AN1853 More Information This Product, www.freescale.com MOTOROLA Basic Refrigeration Evaporator Condenser Freescale Semiconductor, Inc. refrigerant then condenses passes through from high-pressure environment condenser through expansion valve low-pressure evaporation system inside Fridge compartment. evaporating, refrigerant absorbs heat subsequently reduces enclosure temperature. warmer refrigerant circulated outside compartment where cycle repeats under thermal control. From initial power-on this cyclic cooling process take some time reach acceptable operating temperature range, this usually around 8°C. following plot example behavior ambient temperature within domestic fridge compartment from power-on AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note 21°C 0°C. From graph seen that takes approximately minutes reach 7°C. Profile FridgeTemperature Versus Time Temperature Freescale Semiconductor, Inc. Time (minutes) Conventional Fridge Control many domestic fridge appliances, temperature fridge compartment controlled bi-metallic thermostat connected series with single-phase induction motor. motor windings, winding start winding current limiting Positive Temperature Co-efficient Thermistor (PTC) series with start winding. also common practice embed thermal overload motor windings protection event overheating.For example, thermal overload contact will open remove power from motor event overheating caused motor stall condition. contact will then automatically reset closed condition when windings return their normal safe operating temperature. following diagram typical configuration domestic fridge appliance using single-phase induction motor. AN1853 More Information This Product, www.freescale.com MOTOROLA Microcontroller Solution Operation Thermostat Winding Start Winding Freescale Semiconductor, Inc. Winding Thermal Overload Trip MOTOR Operation When temperature fridge compartment rises above pre-selected thermostat setting, bi-metallic contact closes line voltage applied both start windings simultaneously. start winding lower resistance than winding provides initial current surge required start motor. This inrush current subsequently raises temperature increases resistive property, which turn reduces current flow start winding. this point time, current through start winding been minimised PTC, current through winding stable motor continues run. When fridge compartment reaches desired temperature thermostat contact opens, removing power from motor. When compartment temperature again rises, temperature control cycle repeats. Microcontroller Solution HC908KX8 Microcontroller forms heart refrigeration system providing adaptable platform required functionality low-end through range appliances. Using microcontroller refrigeration appliance provide system with various possibilities developing improved efficiency functionality. system under software control, there better scope improving system efficiency with more accurate electronic temperature measurement AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note compressor control. This complimented additional functionality provided from device feature set. typical implementation follows. Compressor Compress Control Temperature Temperat Control User User Interface Interface Internal Internal Light Light Door Door Alarm Alarm Freescale Semiconductor, Inc. System System Status Status LED/LCD LED/LCD Display Display Serial Serial Comms Comms main focus this design implement system solution that will control domestic fridge compressor based temperature measurement, with some additional functionality. Hardware HC908KX8 Microcontroller feature provides number dual multifunction pins that provide convenient application adaptability. number pins configured general Input /Output, Analogue Inputs, Timer Input Capture Output Compare, Keyboard Inputs Serial Communications. There also external Oscillator configuration available, Port some 15mA-sink/source high current pins with software programmable pull-up resistors. demonstration configuration used fridge application shown following schematic diagram. AN1853 More Information This Product, www.freescale.com MOTOROLA Microcontroller Solution Refrigeration System Schematic Diagram Refrigeration System Schematic Diagram feature device accommodates required functionality typical refrigeration system. Alarm Buzzer otor trol witc 110ohm 908KX8 PTA4 PTA3/ PTA2/ /RxD PTB5/TxD PTB6/(OSC1) PTB7/(OSC2) 20kohm 220k Line Sync hron isati 470ohm 470ohm 470ohm Term Bloc inal ompre ssorRelay 1N4148 PTA1/KBD1* PTA0/KBD0* IRQ1* PTB0/AD0 PTB1/AD1 PTB2/AD2 PTB3/AD3 BTB1 Freescale Semiconductor, Inc. Temp erat Comm mpre ssor 40Va Evap orat Temp erat Reg1 MC78L0 BR160 Temp erat Selec er-On Compre ssor Alarm pply 1000uF Refrigeration System Schematic Diagram Functional Overview temperature system primarily dependent three inputs. Negative Temperature Co-efficient Thermistors (NTCs), Potentiometer. used detect fridge ambient temperature other detects Evaporator temperature. potentiometer used select desired ambient temperature fridge. These inputs connected microcontroller Analogue Digital Converter Module. Other application features include audible alarm, used alert user `door open' condition over under temperature conditions, door switch determine status door either open closed, three system status LED's indicate power-on, another which indicates when compressor powered, third which visual indication `door open', `over temperature' `under temperature' alarm condition. contrast previously described conventional compressor control case, more efficient long-term cost-effective solution Compressor Control AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note implemented using microcontroller control compressor motor using triac relay. that previously connected series with start winding longer required, shown following diagram. TRIAC Micro Freescale Semiconductor, Inc. Winding Start Winding Winding hermal Overload Trip MOTOR RELAY Micro sequence events required start Induction motor under software control. relay energised closes contact apply line voltage start windings simultaneously. triac fired first zero crossing point line voltage every successive zero cross-detected period 40mS. normal operation, after this time compressor should have started Triac will non-conducting state until another start sequence invoked. compressor remains powered running whilst relay remains energised. With circuit some cost Watts power saved. Line Voltage Zero Crossover Detection Ideally, motor start winding should energised zero crossing points applied sinusoidal line voltage waveform. zero crossover detection circuitry required enable microcontroller detect these points that Triac fired appropriate time, since zero current, triac naturally switches off. This technique added advantage minimising switching transient generation electromagnetic radiation. zero crossover detection function implemented using timer input capture features device. This input generate interrupt when rising falling edge detected input AN1853 More Information This Product, www.freescale.com MOTOROLA Microcontroller Solution Triac Drive Circuitry capture pin. line voltage connected potential divider drives base Transistor which switches rising falling edges between synchronization with line voltage zero crossover points. When rising falling edge detected, triac controlled from Input Capture Interrupt Service routine. Triac Drive Circuitry Freescale Semiconductor, Inc. triac this application used apply power start winding motor during start-up phase, remove power from this winding once motor started. Interfacing microcontroller triac achieved various ways. main objective connect microcontroller line voltage order provide common electrical reference point between line microcontroller application triac gate pulses. this application, positive ground system used, which requires that microcontroller terminal connected Neutral Terminal purpose this relay apply power compressor motor start windings power-on, maintain power motor winding after start-up phase expired. Additionally, relay contact resistance, does dissipate power unnecessarily under normal running conditions. This conventional arrangement. supply rectified smoothed then passed through linear regulator provide power supply system. power supply relay unregulated shown schematic diagram. This section discusses simple temperature control algorithm accompanied flowcharts code implementation. Consider temperature control profile fridge being divided into three operating bands. These normal operating ranges, over which temperature fridge deemed being acceptable, that between `range max' `range min'. upper lower alarm levels, `alarm max' `alarm min' used constrain over under Compressor Power Relay Power Supply Software 4.10 Temperature Control Algorithm AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note temperature conditions. This shown following temperature profile illustration. Temperature Profile temperature Alarm Alarm Range Compressor Freescale Semiconductor, Inc. Selected Temp Compressor Range Compressor Alarm Alarm time 4.11 Normal Operating Temperature Range From initial power-on, ambient temperature fridge typically around +21°C. user selected temperature typically around +5°C, cycle between +2°C. power-on, temperature within upper alarm region, however, this alarm condition therefore, audible alarm will disabled until temperature driven below `range max' value +8°C first time. Compressor powered over period time drives temperature down through `range max' value through `selected temp' `range min' value +2°C. When temperature reaches this value, compressor powered-down. From this point, temperature will gradually rise through selected temperature eventually reach `range max' value again. this point time, compressor will again powered until temperature driven `range min' value normal temperature control cycle repeats. cycle repetition rate predominately dependant thermal insulation quality frequency door opening. Typically there compressor On/Off work rate. AN1853 More Information This Product, www.freescale.com MOTOROLA Microcontroller Solution Alarm Conditions 4.12 Alarm Conditions There three possible alarm situations. These are, door open, over, under temperature conditions. door inadvertently been opened pre-determined time, example, minute, audible alarm will sounded. over temperature situation occur fridge door closed properly there compressor failure refrigerant pressure problem. under temperature case occur compressor permanently powered-on. these situations objective alert user. After initial power-on, when fridge compartment temperature stabilised, audible alarm will sounded temperature reaches `alarm max' `alarm min' value. also provides visual indication door open, over, under temperature condition. Freescale Semiconductor, Inc. 4.13 Flowcharts There four main software modules used implement control algorithm, initialisation routine which configures microcontroller application parameters. Secondly, `main' temperature control routine which manages application functionality, interrupt service routines. There input capture interrupt service routine used primarily manage zero crossover detection time base module interrupt routine which used provide time reference `door open' alarm delay. following flowcharts illustrate control flow application. Shadowed boxes shown charts indicate nested functions within code. AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note Main Temperature Control Algorithm main Initialise device application parameters Freescale Semiconductor, Inc. power status 'on' flag indicate buzzer alarm read selected temp compressor power 'off' temp above range read temp compressor power temp within normal operating range alarm check temp below range minimum compressor power AN1853 More Information This Product, www.freescale.com MOTOROLA Microcontroller Solution Flowcharts Initialisation Routine call from main disable triac Freescale Semiconductor, Inc. configure oscillator power status 'off' initialise input/output ports compressor status 'off' iniialise timer initialise start phase initialise analogue digital converter alarm status 'off' enable interrupts initialise input capture return de-energise compressor relay AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note call from main Alarm Check Routine door open enable time base module disable time base module Freescale Semiconductor, Inc. enable time base module interrupt disable time base module interrupt door alarm delay expired over under temp alarm alarm status 'on' reset door alarm delay count alarm valid alarm alarm alarm status 'off' return AN1853 More Information This Product, www.freescale.com MOTOROLA Microcontroller Solution Flowcharts icap interrupt Input Capture Interrupt Routine start phase time 40mS Freescale Semiconductor, Inc. start phase expired fire triac increment 'start phase' count disable zero cross detect reset start phase reset input capture flag return AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note Time Base Module Interrupt Routine Freescale Semiconductor, Inc. time base interrupt increment door alarm delay count clear time base interrupt flag return 4.14 Summary Basic conventional fridge control typically uses bi-metallic thermostat control fridge temperature. thermostat simply applies power compressor based course mechanical temperature setting. This method been used past some time rapidly becoming dated, mainly increasing demand more efficient appliances increased user functionality. suggested functionality shown this application example basic simple implement, however, there many additional features that enhance system. example, evaporator temperature measurement included part temperature control cycle. Serial Communications Interface used communicate display, local based system internet gateway remote AN1853 More Information This Product, www.freescale.com MOTOROLA Microcontroller Solution Code Implementation. diagnostic control purposes. Electronic control internal light accommodated using Triac ramp-up compartment illumination. These features enhance marketability appliance considerably. additional safety feature added which detect motor rotation. This implemented using both input captures some additional software detect measure phase difference between start windings during normal running conditions motor stall condition. efficiency system further improved making microcontroller power saving `wait mode' feature with analogue digital converter interrupt. Wait mode invoked when `range min' temperature reached, hence, taking advantage Fridge compartment long temperature rise time constant optimising power conservation. Program execution continue from interrupt routine some time later when temperature rises `range max' value. conclusion, HC908KX8 microcontroller excellent level adaptability very cost, with added advantage having system under software control, ability program re-program flash'. Freescale Semiconductor, Inc. 4.15 Code Implementation. 4.15.1 Main Temperature Control Routine. #include "hc08kx6.h" #include "Fridge.h" source code implement functionality described preceding flowcharts follows, including header files generic hc08kx6 header file*/ application header file Copyright Motorola 1999 Function Name Engineer Location Date Created Current Revision Note main() William Mackay Motorola Microcontroller Division, East Kilbride December 1999 Main temperature control routine AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note void main(void) init(); while(1) POWER_STATUS selected_temp single_adc(AD2); air_temp single_adc(AD0); if(((air_temp) (selected_temp+AIR_MAX_TEMP))&& ((air_temp) (selected_temp-AIR_MIN_TEMP))|| ((air_temp) (selected_temp-AIR_MIN_TEMP))) compressor_off(); alarm_valid SET; power read user selected temp read compartment temp within correct temp range below range minimum flag indicate buzzer sounded.*/ /*.when alarm condition detected Freescale Semiconductor, Inc. else if((!COMPRESSOR_POWER)&& compressor relay de-energised ((air_temp) (selected_temp+AIR_MAX_TEMP))) temp above range compressor_on(); alarm_check(); AN1853 More Information This Product, www.freescale.com MOTOROLA Microcontroller Solution Code Implementation. 4.15.2 Initialisation Routine. Copyright Motorola 1999 Function Name init() Engineer Location Date Created Current Revision William Mackay Motorola Microcontroller Division, East Kilbride December 1999 Function configures oscillator, device modules initialises application parameters Freescale Semiconductor, Inc. Note void init(void) CONFIG1=0x31; Init_osc(); init_ports(); init_timer(); init_time_base(); init_adc(); init_icap(); COMPRESSOR_POWER DISABLED; TRIAC_DRIVE DISABLED; POWER_STATUS OFF; COMPRESSOR_STATUS OFF; ALARM_STATUS OFF; ENABLE_INTERRUPTS; disables sets oscillator frequency configure input/output ports initialise timer initialise time base module initialise analogue digital converter configure input capture compressor relay de-energised triac green yellow enable interrupts AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note 4.15.3 Analogue Digital Conversion Routine. Copyright Motorola 1999 Function Name single_adc() Engineer Location Date Created William Mackay Motorola Microcontroller Division, East Kilbride December 1999 Performs single analogue digital conversion Freescale Semiconductor, Inc. Current Revision Notes unsigned char single_adc(unsigned char channel_number) START_CONVERSION channel_number; delay(); if(CONVERSION_COMPLETE) return(ADC_VALUE); 4.15.4 Compressor Routine. Copyright Motorola 1999 Function Name compressor_off() Engineer Location Date Created Current Revision Note William Mackay Motorola Microcontroller Division, East Kilbride December 1999 Function powers-down compressor void compressor_off(void) COMPRESSOR_POWER DISABLED; ZERO_CROSS_DETECT DISABLED; COMPRESSOR_STATUS OFF; compressor relay de-energised disable icap interrupt compressor AN1853 More Information This Product, www.freescale.com MOTOROLA Microcontroller Solution Code Implementation. 4.15.5 Compressor Routine. Copyright Motorola 1999 Function Name compressor_on() Engineer Location Date Created Current Revision William Mackay Motorola Microcontroller Division, East Kilbride December 1999 Function powers-on compressor Freescale Semiconductor, Inc. Note void compressor_on(void) COMPRESSOR_POWER ENABLED; ZERO_CROSS_DETECT ENABLED; COMPRESSOR_STATUS compressor relay energised start compressor next zero cross 4.15.6 Alarm check Routine. Copyright Motorola 1999 Function Name alarm_check() Engineer Location Date Created Current Revision Note William Mackay Motorola Microcontroller Division, East Kilbride December 1999 Function checks for, door open, over under temperature alarm conditions void alarm_check(void) if(DOOR_OPEN) TBCR_TBON SET; TBCR_TBIE ENABLED; else TBCR_TBON RESET; TBCR_TBIE DISABLED; door_alarm_delay RESET; enable time base module enable time base interrupt disable time base reset counter zero disable time base interrupt AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note if((door_alarm_delay ONE_MINUTE)|| (air_temp ALARM_TEMP_MAX)|| (air_temp ALARM_TEMP_MIN)) ALARM_STATUS if(alarm_valid) BUZZER else BUZZER OFF; ALARM_STATUS OFF; door opened minute greater over temp alarm under temp alarm alarm alarm condition valid audible alarm Freescale Semiconductor, Inc. 4.15.7 Input Capture Interrupt Routine. Copyright Motorola 1999 Function Name input_capture() Engineer Location Date Created Current Revision Note William Mackay Motorola Microcontroller Division, East Kilbride December 1999 Preliminary This pulses triac line voltage zero-cross detection pre-defined motor start period #pragma TRAP_PROC SAVE_REGS void input_capture() if(start_phase START_TIME) TRIAC_DRIVE OFF; delay(); TRIAC_DRIVE ++start_phase; else ZERO_CROSS_DETECT DISABLED; start_phase RESET; read_register TSC0 ICAP_FLAG RESET; start phase valid apply pulse triac start phase count line voltage zero cross points start time expired disable input capture interrupt reset start phase reads status control register resets CH0F flag AN1853 More Information This Product, www.freescale.com MOTOROLA Microcontroller Solution Code Implementation. 4.15.8 Time Base Module Interrupt Routine. Copyright Motorola 1999 Function Name time_base() Engineer Location Date Created Current Revision William Mackay Motorola Microcontroller Division, East Kilbride December 1999 This increments count door alarm delay period Freescale Semiconductor, Inc. Note #pragma TRAP_PROC SAVE_REGS void time_base() ++door_alarm_delay; TBCR_TACK SET; increment counter rollover clear time base interrupt flag 4.15.9 Oscillator Initialisation Routine. Copyright Motorola 1999 Function Name init_osc() Engineer Location Date Created Current Revision Note William Mackay Motorola Microcontroller Division, East Kilbride December 1999 Function sets oscillator frequency void init_osc(void) ICGMR_N0 SET; ICGMR_N1 RESET; ICGMR_N2 SET; ICGMR_N3 SET; ICGMR_N4 SET; ICGMR_N5 RESET; ICGMR_N6 RESET; oscillator frequency multipier 29x307.2khz 8.9Mhz 2.27Mhz freq AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note 4.15.10 Initialise input/output Ports. Copyright Motorola 1999 Function Name init_ports() Engineer Location Date Created Current Revision Note William Mackay Motorola Microcontroller Division, East Kilbride December 1999 input/output port configuration Freescale Semiconductor, Inc. void init_ports(void) DDRA_BIT0 OUTPUT; DDRA_BIT1 OUTPUT; DDRA_BIT3 OUTPUT; DDRA_BIT4 INPUT; PTAPUE_BIT4 SET; DDRB_BIT0 INPUT; DDRB_BIT1 INPUT; DDRB_BIT2 INPUT; DDRB_BIT3 OUTPUT; DDRB_BIT6 OUTPUT; DDRB_BIT7 OUTPUT; relay buzzer triac drive door enable pull-up temp evaporator temp temp select power `on' alarm indicator compressor `on' 4.15.11 Initialise Analogue Digital Converter. Copyright Motorola 1999 Function Name init_adc() Engineer Location Date Created Current Revision Notes William Mackay Motorola Microcontroller Division, East Kilbride December 1999 Function sets clock source divide ratio void init_adc(void) ADCLK_ADICLK ADCLK_ADIV0 ADCLK_ADIV1 ADCLK_ADIV2 SET; RESET; RESET; RESET; internal clock clock source clock divide ratio AN1853 More Information This Product, www.freescale.com MOTOROLA Microcontroller Solution Code Implementation. 4.15.12 Delay Routine. Copyright Motorola 1999 Function Name delay() Engineer Location Date Created William Mackay Motorola Microcontroller Division, East Kilbride December 1999 This delay accommodates Triac pulse duration analogue digital conversion time delay Freescale Semiconductor, Inc. Current Revision Note void delay(void) unsigned char i,j; for(i=0; i<2; i++) for(j=0; j<2; j++); 4.15.13 Initialise Timer. Copyright Motorola 1999 Function Name init_timer() Engineer Location Date Created Current Revision Note William Mackay Motorola Microcontroller Division, East Kilbride December 1999 Function used configure timer interface module. Sets internal clock pre-scalar timer counter void init_timer(void) RESET; internal clock divide AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note 4.15.14 Initialise Time Base Module. Copyright Motorola 1999 Function Name init_time_base() Engineer Location Date Created Current Revision Note William Mackay Motorola Microcontroller Division, East Kilbride December 1999 Initialises time base module interrupt rate Freescale Semiconductor, Inc. void init_time_base(void) TBCR_TBR0 RESET; TBCR_TBR1 RESET; TBCR_TBR2 RESET; sets interrupt divider 32768 4.15.15 Initialise Input Capture. Copyright Motorola 1999 Function Name init_icap() Engineer Location Date Created Current Revision Note William Mackay Motorola Microcontroller Division, East Kilbride December 1999 This function configures timer channel zero input capture rising falling edge detection void init_icap(void) TSC0_MS0A RESET; TSC0_MS0B RESET; TSC0_ELS0A SET; TSC0_ELS0B SET; TSC0_CH0IE SET; mode select input capture capture rising falling edge enable interrupts AN1853 More Information This Product, www.freescale.com MOTOROLA Microcontroller Solution Code Implementation. 4.15.16 HC08KX8 Generic Header File Copyright Motorola 1999 File Name HC08KX8.h Author Location Date Created Current Revision William Mackay Motorola Microcontroller Division, East Kilbride December 1999 This file maps 68HC908KX8 Register required fridge application. registers mapped defined General Release Specification. Freescale Semiconductor, Inc. Notes #ifndef _HC08KX8_H #define _HC08KX8_H Register Mapping Structures Macros #define #define REGISTER(a) (*((volatile unsigned char *)(a))) BIT(a,b) (((vbitfield *)(a))->bit##b) assumes right left order typedef volatile struct{ volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned volatile unsigned vbitfield; bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note Input Output Ports Port Data register #define #define PTA_BIT0 #define PTA_BIT1 #define PTA_BIT2 #define PTA_BIT3 #define PTA_BIT4 REGISTER(0x00) BIT(0x00,0) BIT(0x00,1) BIT(0x00,2) BIT(0x00,3) BIT(0x00,4) Freescale Semiconductor, Inc. Port Data register #define REGISTER(0x01) #define PTB_BIT0 BIT(0x01,0) #define PTB_BIT1 BIT(0x01,1) #define PTB_BIT2 BIT(0x01,2) #define PTB_BIT3 BIT(0x01,3) #define PTB_BIT4 BIT(0x01,4) #define PTB_BIT5 BIT(0x01,5) #define PTB_BIT6 BIT(0x01,6) #define PTB_BIT7 BIT(0x01,7) Port Data Direction Register #define DDRA REGISTER(0x04) #define DDRA_BIT0 BIT(0x04,0) #define DDRA_BIT1 BIT(0x04,1) #define DDRA_BIT2 BIT(0x04,2) #define DDRA_BIT3 BIT(0x04,3) #define DDRA_BIT4 BIT(0x04,4) Port Input Pull Enable Register #define PTAPUE REGISTER(0x0D) #define PTAPUE_BIT0 BIT(0x0D,0) #define PTAPUE_BIT1 BIT(0x0D,1) #define PTAPUE_BIT2 BIT(0x0D,2) #define PTAPUE_BIT3 BIT(0x0D,3) #define PTAPUE_BIT4 BIT(0x0D,4) Port Data Direction Register #define DDRB REGISTER(0x05) #define DDRB_BIT0 BIT(0x05,0) #define DDRB_BIT1 BIT(0x05,1) #define DDRB_BIT2 BIT(0x05,2) #define DDRB_BIT3 BIT(0x05,3) #define DDRB_BIT4 BIT(0x05,4) #define DDRB_BIT5 BIT(0x05,5) #define DDRB_BIT6 BIT(0x05,6) #define DDRB_BIT7 BIT(0x05,7) AN1853 More Information This Product, www.freescale.com MOTOROLA Microcontroller Solution Code Implementation. Time Base Register #define #define #define #define #define #define #define #define TBCR TBCR_TBON TBCR_TBIE TBCR_TACK TBCR_TBR0 TBCR_TBR1 TBCR_TBR2 TBCR_TBIF REGISTER(0x1C) BIT(0x1C,1) BIT(0x1C,2) BIT(0x1C,3) BIT(0x1C,4) BIT(0x1C,5) BIT(0x1C,6) BIT(0x1C,7) Freescale Semiconductor, Inc. Configuration Write-Once Registers #define #define CONFIG2 CONFIG1 REGISTER(0x1e) REGISTER(0x1F) Timer Registers Timer Status Control #define #define TSC_PS0 #define TSC_PS1 #define TSC_PS2 #define TSC_TRST #define TSC_TSTOP #define TSC_TOIE #define TSC_TOF Register REGISTER(0x20) BIT(0x20,0) BIT(0x20,1) BIT(0x20,2) BIT(0x20,4) BIT(0x20,5) BIT(0x20,6) BIT(0x20,7) Timer Counter Register #define TCNTH REGISTER(0x21) #define TCNTL REGISTER(0x22) Timer Modulo Register #define TMODH #define TMODL REGISTER(0x23) REGISTER(0x24) Register Channel REGISTER(0x25) BIT(0x25,0) BIT(0x25,1) BIT(0x25,2) BIT(0x25,3) BIT(0x25,4) BIT(0x25,5) BIT(0x25,6) BIT(0x25,7) Timer Status Control #define TSC0 #define TSC0_CH0MAX #define TSC0_TOV0 #define TSC0_ELS0A #define TSC0_ELS0B #define TSC0_MS0A #define TSC0_MS0B #define TSC0_CH0IE #define TSC0_CH0F AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note Timer Channel Register #define TCH0H REGISTER(0x26) #define TCH0L REGISTER(0x27) Timer Status Control #define TSC1 #define TSC1_CH1MAX #define TSC1_TOV1 #define TSC1_ELS1A #define TSC1_ELS1B #define TSC1_MS1A #define TSC1_CH1IE #define TSC1_CH1F Register Channel REGISTER(0x28) BIT(0x28,0) BIT(0x28,1) BIT(0x28,2) BIT(0x28,3) BIT(0x28,4) BIT(0x28,6) BIT(0x28,7) Freescale Semiconductor, Inc. Timer Channel Register #define TCH1H REGISTER(0x29) #define TCH1L REGISTER(0x2a) Registers Control Register #define ICGCR #define ICGCR_ECGS #define ICGCR_ECGON #define ICGCR_ICGS #define ICGCR_ICGON #define ICGCR_CS #define ICGCR_CMON #define ICGCR_CMF #define ICGCR_CMIE REGISTER(0x36) BIT(0x36,0) BIT(0x36,1) BIT(0x36,2) BIT(0x36,3) BIT(0x36,4) BIT(0x36,5) BIT(0x36,6) BIT(0x36,7) Multiply Register #define ICGMR REGISTER(0x37) #define ICGMR_N0 BIT(0x37,0) #define ICGMR_N1 BIT(0x37,1) #define ICGMR_N2 BIT(0x37,2) #define ICGMR_N3 BIT(0x37,3) #define ICGMR_N4 BIT(0x37,4) #define ICGMR_N5 BIT(0x37,5) #define ICGMR_N6 BIT(0x37,6) Trim Register #define ICGTR #define ICGTR_TRIM0 #define ICGTR_TRIM1 #define ICGTR_TRIM2 #define ICGTR_TRIM3 #define ICGTR_TRIM4 #define ICGTR_TRIM5 #define ICGTR_TRIM6 #define ICGTR_TRIM7 REGISTER(0x38) BIT(0x38,0) BIT(0x38,1) BIT(0x38,2) BIT(0x38,3) BIT(0x38,4) BIT(0x38,5) BIT(0x38,6) BIT(0x38,7) AN1853 More Information This Product, www.freescale.com MOTOROLA Microcontroller Solution Code Implementation. Analogue Digital Converter Registers Status Control Register #define ADSCR REGISTER(0x3c) #define ADSCR_ADCH0 BIT(0x3c,0) #define ADSCR_ADCH1 BIT(0x3c,1) #define ADSCR_ADCH2 BIT(0x3c,2) #define ADSCR_ADCH3 BIT(0x3c,3) #define ADSCR_ADCH4 BIT(0x3c,4) #define ADSCR_ADCO BIT(0x3c,5) #define ADSCR_AIEN BIT(0x3c,6) #define ADSCR_COCO BIT(0x3c,7) A/D-Data Register #define Input #define #define #define #define #define Clock Register ADCLK ADCLK_ADICLK ADCLK_ADIV0 ADCLK_ADIV1 ADCLK_ADIV2 Freescale Semiconductor, Inc. REGISTER(0x3d) REGISTER(0x3e) BIT(0x3e,4) BIT(0x3e,5) BIT(0x3e,6) BIT(0x3e,7) Voltage Inhibit Register Status Register #define LVISR #define LVISR_LVIOUT #endif REGISTER(0xFE0C) BIT(0xFE0C,7) AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note 4.15.17 Application Header File. Copyright Motorola 1999 File Name Fridge.h Engineer Location Date Created Current Revision Notes William Mackay Motorola Microcontroller Division, East Kilbride December 1999 This file contains application specific definitions Freescale Semiconductor, Inc. #ifndef _FRIDGE_H #define _FRIDGE_H Constant Definitions #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define RESET CLEAR ENABLED DISABLED0 OUTPUT INPUT START_TIME AIR_MAX_TEMP AIR_MIN_TEMP ALARM_TEMP_MAX ALARM_TEMP_MIN ONE_MINUTE TEN_SECONDS 0x28 0x33 0x33 0xE8 0x1A 0x3FAB 0x01B2 motor start-up period (40mS) maximum temperature minimum temperature 4.5V maximum alarm temperature 0.5V minimum alarm temperature count time base module divider 32768 count time base module divider 32768 Input/Output Port Application Definitions #define #define #define #define #define #define #define COMPRESSOR_POWER BUZZER DOOR_OPEN TRIAC_DRIVE POWER_STATUS COMPRESSOR_STATUS ALARM_STATUS PTA_BIT0 PTA_BIT1 PTA_BIT4 PTA_BIT3 PTB_BIT3 PTB_BIT7 PTB_BIT6 AN1853 More Information This Product, www.freescale.com MOTOROLA Microcontroller Solution Code Implementation. Analogue channel definitions #define #define #define #define Data Register Freescale Semiconductor, Inc. #define ADC_VALUE Status Control Register #define #define #define #define START_CONVERSION CONVERSION_COMPLETE ADC_INTERRUPT CONVERSION_MODE ADSCR ADSCR_COCO ADCSR_AIEN ADCSR_ADCO Timer #define #define ZERO_CROSS_DETECT ICAP_FLAG TSC0_CH0IE TSC0_CH0F Function Prototypes void main (void); void init(void); void InputCapture(void); void delay(void); unsigned char single_adc(unsigned char); void init_osc(void); void compressor_on(void); void compressor_off(void); void alarm_check(void); void init_adc(void); void init_ports(void); void init_timer(void); void init_time_base(); void init_icap(void); void reset_icap(void); AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Application Note Global Variables Zero Page #pragma unsigned unsigned unsigned unsigned unsigned unsigned variables DATA_SEG _DATA_ZEROPAGE char air_temp; char selected_temp; char start_phase; char door_alarm_delay; char alarm_valid; char read_register fridge compartment temperature user selected temperature indicates status start time interval time base count door open alarm delay flag indicate buzzer sounded /*.when alarm condition detected dummy read location flag clearing Freescale Semiconductor, Inc. Interrupt Definitions #define #define #endif ENABLE_INTERRUPTS DISABLE_INTERRUPTS cli; sei; AN1853 More Information This Product, www.freescale.com MOTOROLA Microcontroller Solution Code Implementation. Freescale Semiconductor, Inc. AN1853 MOTOROLA More Information This Product, www.freescale.com Freescale Semiconductor, Inc. Motorola reserves right make changes without further notice products herein. Motorola makes warranty, representation guarantee regarding suitability products particular purpose, does Motorola assume liability arising application product circuit, specifically disclaims liability, including without limitation consequential incidental damages. "Typical" parameters which provided Motorola data sheets and/or specifications vary different applications actual performance vary over time. operating parameters, including "Typicals" must validated each customer application customer's technical experts. Motorola does convey license under patent rights rights others. Motorola products designed, intended, authorized components systems intended surgical implant into body, other applications intended support sustain life, other application which failure Motorola product could create situation where personal injury death occur. Should Buyer purchase Motorola products such unintended unauthorized application, Buyer shall indemnify hold Motorola officers, employees, subsidiaries, affiliates, distributors harmless against claims, costs, damages, expenses, reasonable attorney fees arising directly indirectly, claim personal injury death associated with such unintended unauthorized use, even such claim alleges that Motorola negligent regarding design manufacture part. Motorola registered trademarks Motorola, Inc. Motorola, Inc. Equal Opportunity/Affirmative Action Employer. reach USA/EUROPE: Motorola Literature Distribution; P.O. 5405, Denver, Colorado 80217. 1-303-675-2140 Mfax: RMFAX0@email.sps.mot.com TOUCHTONE 602-244-6609, http://sps.motorola.com/mfax CANADA ONLY: http://sps.motorola.com/mfax HOME PAGE: http://motorola.com/sps/ JAPAN: Motorola Japan Ltd.; SPS, Technial Information Center, 3-20-1, Minami-Azabu, Minato-ku, Tokyo 106-8573 Japan. 81-3-3440-3569 ASIA/PACIFIC: Motorola Semiconductors H.K. Ltd.; Silicon Harbour Centre, King Street, Industrial Estate, N.T., Hong Kong. 852-266668334 CUSTOMER FOCUS CENTER: 1-800-521-6274 Mfax trademark Motorola, Inc. Motorola, Inc., 2000 AN1853/D More Information This Product, www.freescale.com Other recent searchesSBR40U150CT - SBR40U150CT SBR40U150CT Datasheet SBR40U150CTF - SBR40U150CTF SBR40U150CTF Datasheet SBR40U150CTI - SBR40U150CTI SBR40U150CTI Datasheet SBR40U150CTB - SBR40U150CTB SBR40U150CTB Datasheet MGSF2P02HD - MGSF2P02HD MGSF2P02HD Datasheet FP102 - FP102 FP102 Datasheet F4100 - F4100 F4100 Datasheet DF2S20CT - DF2S20CT DF2S20CT Datasheet BC638 - BC638 BC638 Datasheet BC640 - BC640 BC640 Datasheet BC640-16 - BC640-16 BC640-16 Datasheet
Privacy Policy | Disclaimer |