19 of 307
ZBasic System Library 9 ZX Microcontroller Family before calling a System Library routine that disables interrupts. This is not as critical for a hardware- based serial channel (e.g. Com1) as it is for the software-based serial channels Com3 to Com6. There is no way, however, to work around the problem of serial input data arriving while interrupts are disabled. The hardware-based serial channels will store one received character and hold it while interrupts are disabled but if a second character arrives while interrupts are disabled it will be lost. Channels 3-6 rely on interrupts for every bit received so the situation is much more problematic. In this case, having interrupts disabled for longer than approximately one-third of the bit time will likely cause garbled input if a character’s transmit time overlaps the period when interrupts are disabled. For characters being transmitted by channels 3-6, having interrupts disabled for more than about 10% of the bit time may cause the receiver to lose synchronization. For reference purposes, the table below indicates which I/O routines disable interrupts for the duration of their execution. See the individual descriptions for more detailed information. System Library Routines that Disable Interrupts CountTransitions I2CPutByte RCTime DACPin PlaySound Reset1Wire FreqOut PulseIn ShiftIn Get1Wire PulseOut ShiftInEx Get1WireByte Put1Wire ShiftOut Get1WireData Put1WireByte ShiftOutEx I2CCmd Put1WireData I2CGetByte PutDAC Interrupt Service Routines For the native code devices (e.g. ZX-24n), a few interrupt service routines (ISRs) are always included in your program (e.g. for Com1 and the RTC) while others are included only if certain System Library routines are used in your program. In some cases, the additional ISRs that are included when a specific System Library routine is used depends on how the routine is invoked and what the compiler can deduce regarding which ISRs might be needed. For example, if OpenCom() is invoked one or more times but the compiler can determine that the Com1 is always the channel being used, no additional ISRs are included since the Com1 ISRs are always included. On the other hand, if the compiler cannot determine which channel is being opened in one or more cases, it includes the ISRs for all Com channels, both hardware- based and software-based channels. In the description of each System Library routine, information is given about the set of ISRs might be included in your program if you use that routine. This information is only important, of course, if you are also providing one or more ISRs in your code because conflicts may arise. (See the section entitled “Defining Interrupt Service Routines” in the ZBasic Language Reference Manual for more information on how this is done.) The table below gives an overview of which System Library routines may cause ISRs to be included atomatically in your program. The shaded entries represent ISRs that are always included. System Library Routines that May Load ISRs Routine mega644P mega328P mega128 mega1281 mega1280 ADCtoCom1() Timer1_CompA Timer1_CompA Timer1_CompA Timer4_CompA Timer4_CompA Com1toDAC() Timer1_CompA Timer1_CompA Timer1_CompA Timer4_CompA Timer4_CompA InputCapture() Timer1_Capt Timer1_Ovf Timer1_Capt Timer1_Ovf Timer1_Capt Timer1_Ovf Timer3_Capt Timer3_Ovf Timer1_Capt Timer1_Ovf Timer3_Capt Timer3_Ovf Timer1_Capt Timer1_Ovf Timer3_Capt Timer3_Ovf Timer4_Capt Timer4_Ovf Timer5_Capt Timer5_Ovf OpenCom() USART0_RX USART0_TX USART0_UDRE USART0_RX USART0_TX USART0_UDRE USART0_RX USART0_TX USART0_UDRE USART0_RX USART0_TX USART0_UDRE USART0_RX USART0_TX USART0_UDRE