Start Back Next End
  
ZBasic System Library
ZBasic Microcontrollers
8
when the download baud rate is changed.  Users have reported success with baud rates as high as
460800 but higher rates may also work if your serial hardware support them.
Pins Supported for I/O Routines
Because GPIO16 (B.0) is realized using different circuitry than is used for GPIO0-GPIO15 (A.0-A.15), not
all of the I/O routines support GPIO16.  The I/O routines that do support GPIO16 are listed below.
GetPin()
PutPin()
PulseIn()
PulseOut()
Other differences between the port A pins and the port B pin are that B.0 cannot generate a pin change
event nor it is able to operate in "open drain" mode.  Additionally, B.0 has no "input with pullup" mode.
Differences in System Library Routines
Some of the ZBasic System Library routines operate with different timing and/or different restrictions on
the ESP8366 as compared to AVR targets.  The discussion below summarizes the differences.
CountTransitions() - The sampling loop is about 65 CPU cycles (800nS at 80MHz).  Although interrupts
are disabled, non-maskable interrupts may still occur that cause a pair of closely spaced transitions to be
missed.
Delay() - The resolution of the delay time is 1mS.
GetElapsedMicroTime()
GetMicroTime() - The Microtime_t structure is 6 bytes in length.  The resolution of the 32-bit fastTicks
element is 1mS while the resolution of the 16-bit timerTicks element is 200nS.
OpenI2C() - Only one I2C channel is supported and, since the ESP8266 has no I2C hardware, the I2C
protocol is implemented in software using the specified pins for SDA and SCL.  The default bit rate is
about 450KHz.  The bitRate value of 10 will yield a bit rate of about  400KHz, 50 will yield about 200KHz
and 120 will yield about 100KHz.
OpenPWM() - PWM is available only on PortA pins and is implemented in software based on the
ESP8266 RTC Timer1 (a 24-bit down counter).  Only one PWM signal can be generated at any one time
and the channel parameter is the desired pin number.  The minimum supported base frequency is 1.0Hz
and the maximum is about 78KHz.  Note, however, that lower frequencies are to be preferred due to the
lower load imposed on the CPU.
OpenSPI() - Only one SPI channel is supported and the SPI protocol is implemented in software using
the pins specified in the DefineSPI() call.  The bit rate portion of the flags parameter is ignored.  The
SPI clock frequency is approximately 1MHz when running at 80MHz.
PulseIn() - The value returned is the number of RTC Timer2 ticks, divided by the Register.TimerSpeed1
divisor value, corresponding to the pulse width with a resolution of 200nS. Although interrupts are
disabled, non-maskable interrupts may still occur that can cause a transition to be detected later than it
occurs.
PulseOut() - The units of the pulse width is 200nS multiplied by the Register.TimerSpeed1 divisor.
Although interrupts are disabled, non-maskable interrupts may still occur that cause a transition to be
later than it should be.
PutPin() - When generating a pulse (mode = 5), the pulse width is about 250 nS.  Also, an additional
mode OpenDrain (mode=9, zxOpenDrain) is available.  The opposite mode is ActivePullup (mode=10,
zbActivePullup).
Previous page Top Next page