jalapi

Welcome to jalapi, the jallib API documentation

http://jallib.googlecode.com

Table of Content

adc
adc_channels
adc_clock
adc_hardware
calendar
co2_t6603
delay
eeprom_24lc256
fat32
format
humidity_sht
i2c_hardware
i2c_hw_slave
i2c_hw_slave_isr
i2c_hw_slave_msg
i2c_level1
i2c_software
ir_ranger_gp2d02
jascii
keyboard
large_array_1
large_array_2
large_array_3
large_array_4
lcd_backlight
lcd_hd44780_4
lcd_hd44780_8
lcd_hd44780_common
lcd_hd44780_serial_sw
math
pata_hard_disk
pic_data_eeprom
print
profiler
pwm_ccp1
pwm_ccp10
pwm_ccp2
pwm_ccp3
pwm_ccp4
pwm_ccp5
pwm_ccp6
pwm_ccp7
pwm_ccp8
pwm_ccp9
pwm_common
pwm_hardware
queue01
queue02
queue03
queue04
random
rtc_isr_tmr0
sd_card
serial_hardware
serial_hw_int_cts
serial_software
seven_segment
spi_master_hw
sram_23k256
temperature_tc77
timer0_isr_interval
unittest
usart_common
usb_defs
usb_drv
usb_drv_cdc_class
usb_drv_core
usb_serial

adc

ADC hardware, built-in PIC ADC module

Author Stef Mientki, Copyright (c) 2002..2008, all rights reserved.
Adapted-by Sebastien Lelong.
Compiler >=2.4k

Description

library to handle ADC peripheral.
  - support both low and high resolution mode
  - support a large number of PICs, with
      - ADC pin configuration
      - channel selection
      - clock selection
  - support Vref



How to use it ? See http://jallib.blogspot.com for details...


Notes

this is a heavy refactoring/rewriting of original library from Stef Mientki.
The main changes are about ADC configuration, which are essentially handled in 
adc_channels.jal, adc_pindef.jal and adc_clock.jal



The original library can be found:
   - Stef's: http://mientki.ruhosting.nl/pic-tools/jal/libs2/adc_hardware.jal
   - jallib issue tracker: http://code.google.com/p/jallib/issues/detail?id=7


Dependencies


Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

  • adc_init()

    Initializes the PIC AD-converter,
    by calling the correct routine according to the number of external references
    Settings are done according to the special ADC constants
    Sets all the analog pins to input
    Calculates aquisition time and determines if right or 
    left justification is optimal
    

  • adc_read_bytes(byte in adc_chan, byte out adc_hbyte, byte out adc_lbyte)

    Does an AD conversion on the selected channel
    returns the 10-bit result as 2 byte parameters
    It doesn't matter if ADC is set to low or high resolution
    

Private

Functions


Related samples

Here are the list of samples which use this library:

12f68312f683_pwm_adc.jal
16f76716f767_pwm_adc.jal
16f7716f77_adc_lowres.jal
16f876a16f876a_adc.jal
16f87716f877_adc.jal
16f8816f88_adc_lowres.jal
16f8816f88_adc_highres.jal
16f88616f886_pwm_adc_res.jal
16f88616f886_pwm_adc_freq.jal



adc_channels

ADC channel configuration.

Author Sebastien Lelong, Copyright (C) 2009, all rights reserved.
Adapted-by
Compiler >=2.4k

Description

this library acts as a wrapper. When included, it'll define ways to
configure the number ADC channels. There are 3 different cases:
   1. the number of channels is specified setting/clearing PCFG bits
      => a combination of PCFG bits selects a given number of ADC channels.
         It is not possible to independently select which pins as ADC pins.
         If available, Vref+ and Vref- are part of these combinations.
         PCFG bits are in ADCON1, as ADCON1_PCFG
   2. the number of channels is specified clearing PCFG bits (case only found in 18F, I think)
      => pins can be configured independently (you can decide which pin will act as
         an analog pin, and define your own combination
         Vref+/Vref- are configured using VCFG bits.
         PCFG bits are in ADCON0 and ADCON1, and are numbered (eg. ADCON_PCFG5)
   3. the number of channels is set using ANS bits (18F and non-18F)
      => same as case 2., channels can be configured independently
         Vref+/Vref- are configured using VCFG bits.


Notes

this file is generated, don't modify it directly...


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • adc_adref()

    Configure Voltage reference using ADREF bits
    Found in PICs: 16f722, 16f723, 16f724, 16f726, 16f727, 16lf722, 
                   16lf723, 16lf724, 16lf726, 16lf727,
    Same family, DS 41341B
    

  • adc_vcfg()

    Configure Voltage reference using VCFG bits
    

Functions


Related samples

No sample found


adc_clock

ADC block configuration

Author Sebastien Lelong, Copyright (c) 2009, all rights reserved.
Adapted-by Sebastien Lelong.
Compiler >=2.4k

Description

this library provides a procedure to configure
ADC clock according to ADC constraints about Tad values and PIC's clock speed


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Private

Functions

Private

API details

Global variables/contants

Procedures

Private

Functions

Private

Related samples

No sample found


adc_hardware

ADC hardware, built-in PIC ADC module

Author Stef Mientki, Copyright (c) 2002..2008, all rights reserved.
Adapted-by Sebastien Lelong.
Compiler >=2.4g

Description

library to use the PIC's AD converter
See 16F87x datasheet (DS30292C, p112)
Number of channels, behind "--" yields only for 16F874 and 16F877
No external Vref: Nchan = 1,3,5 -- 6,8
Only external +Vref: Nchan = 2,4 -- 5,7
Both external +Vref and - Vref: Nchan = 1,2,3 -- 4,6



Analog channels can still be used as digital outputs, by setting
    pin = output



relevant IO pins
 * RA0 = AN0
 * RA1 = AN1
 * RA2 = AN2  or  -Vref
 * RA3 = AN3  or  +Vref
 * RA4 = no analog IO
 * RA5 = AN4
 * next pins only for 16F874 and 16F877
 * RE0 = AN5
 * RE1 = AN6
 * RE2 = AN7






Example PIC-AD


 (if you use JALcc, you can copy the complete example below and "uncomment" it)


 define the AD converter settings
const ADC_hardware_Nchan      = 2         ;number of selected channels
const ADC_hardware_NVref      = 0         ;number of external references
const ADC_hardware_Rsource    = 10_000    ;maximum source resistance
const ADC_hardware_high_resolution = true ;true = high resolution = 10 bits
                                          ;false = low resolution = 8 bits


 get the library, after defining the constants
include adc_hardware





 initialize the AD converter according to the above parameters
ADC_init





 now take a sample 


 read high resolution, channel 0
var_word=adc_read(0)


 read low resolution, channel 0
var_byte=adc_read_low_res(0)  


Sources

I (Stef) mixed the following libraries with my own ideas
 * f877_modules.jal from Javier Martinez
 * janalog.jal from Vasile Surducan


Dependencies


Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

  • adc_read_bytes(byte in adc_chan, byte out adc_hbyte, byte out adc_lbyte)

    Does an AD conversion on the selected channel
    returns the 10-bit result as 2 byte parameters
    It doesn't matter if ADC is set to low or high resolution
    

  • adc_on()

    Turns all ADC channels back on
    

  • adc_init()

    Initializes the PIC AD-converter,
    by calling the correct routine according to the number of external references
    Settings are done according to the special ADC constants
    Sets all the analog pins to input
    Calculates aquisition time and determines if right or 
    left justification is optimal
    

Private
  • _adc_read_low_res(byte in adc_chan, byte out adc_byte)

    Does an AD conversion with low resolution (8 bit) on the selected channel
    

  • _adc_init_2_vref()

    Initializes the PIC AD-converter, when both +Vref and -Vref are present
    Settings are done according to the special ADC constants
    Sets all the analog pins to input
    Calculates aquisition time and determines if right or 
    left justification is optimal
    

  • _adc_init_1_vref()

    Initializes the PIC AD-converter, when only +Vref is present
    Settings are done according to the special ADC constants
    Sets all the analog pins to input
    Calculates aquisition time and determines if right or 
    left justification is optimal
    

  • _adc_init_no_vref()

    Initializes the PIC AD-converter, when no external Vref is present
    Settings are done according to the special ADC constants
    Sets all the analog pins to input
    Calculates aquisition time and determines if right or 
    left justification is optimal
    

  • _ad_init_general()

    Internal routine, that
    calculates aquisition time
    and determines if right or left justification is optimal
    


Functions


Related samples

Here are the list of samples which use this library:

18f14k5018f14k50_usb_hid_generic.jal
18f245018f2450_usb_hid_generic.jal
18f455018f4550_usb_hid_generic.jal



calendar

Calendar, takes care of ranges for seconds, minutes, date, month, year

Author Eur van Andel, Copyright (c) 2008, all rights reserved.
Adapted-by
Compiler >=2.4h

Description

This library has only one fuction: calendar(). It assumes the following variables:
var volatile byte seconds (typically updated by an ISR)
var byte hours, minutes, date, month
var word year
It knows the leap years until 2099.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f876a16f876a_rtc_lcd.jal
16f877a16f877a_rtc_lcd.jal
16f88616f886_rtc_lcd_4mhz.jal
16f88616f886_rtc_lcd_20mhz.jal
16f88616f886_rtc_lcd_125khz.jal



co2_t6603

T6603_CO2, read values from GE/Telaire T6603 CO2 sensor.

Author Eur van Andel, eur@fiwihex.nl Copyright (c) 2008
Adapted-by Albert Faber
Compiler =2.4m

Description

this library communicates with the T6603 GE/Telaire CO2 sensor.
This sensor uses the Telaire Tsunami-Lite Commnications Protocol 
(no kidding), which is a definition with zero hits on Google. 
available functions are:
get_status() return byte
get_co2_ppm() return word           -- CO2 concentration in ppm 
get_serial_numer() return string[15]
get_elevation_m() return word       -- in meters above sea level


Sources

The brochure is here: www.gesensing.com/downloads/datasheets/920-419A_LR.pdf
Some clippings from the protocol document:


------------ START OF PROTOCOL DOCUMENT CLIPPINGS  ---------------------


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions

  • get_co2_elevation_m() return word

    returns programmed elevation above sea level in meters
    this elevation is uses to calculate CO2 concentration correctly
    

  • get_co2_ppm() return word

    returns a word with CO2 concentration in ppm
    note: if sensor is busy measuring the CO2 values, it will give garbage reply
    reply is checked for garbage and if so, *PREVIOUS* ppm value is returned
    

  • get_co2_status() return byte

    returns status byte. bit_0 = error, bit_1 = warmup, 
    bit_2 = calibration, bit_3 = idle
    


Related samples

Here are the list of samples which use this library:

16f876a16f876a_t6603.jal
16f877a16f877a_co2_t6603.jal



delay

Delays procedures at any processor frequency

Author Stef Mientki, Copyright (c) 2002..2006, all rights reserved.
Adapted-by Sebastien Lelong, Rob Hamerling.
Compiler >=2.4g

Description

library for delays at any processor frequency.
It's based on the JAL v2 compiler generator _usec_delay.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f648a16f648a_serial_hw_int_cts.jal
16f648a16f648a_serial_print.jal
16f648a16f648a_random.jal
16f648a16f648a_serial_format.jal
16f648a16f648a_lcd_hd44780_4_4.jal
16f648a16f648a_serial_hardware.jal
16f648a16f648a_i2c_sw_l1.jal
16f648a16f648a_lcd_hd44780_4_1.jal
16f648a16f648a_backlight.jal
16f67616f676_lcd_hd44780_4_4.jal
16f67616f676_lcd_hd44780_4_1.jal
16f69016f690_lcd_hd44780_4_4.jal
16f69016f690_lcd_hd44780_4_1.jal
16f72316f723_serial_print.jal
16f72316f723_random.jal
16f72316f723_serial_hw_int_cts.jal
16f72316f723_i2c_sw_l1.jal
16f72316f723_serial_hardware.jal
16f72316f723_serial_format.jal
16f72616f726_lcd_hd44780_4_4.jal
16f72616f726_lcd_hd44780_4_1.jal
16f72716f727_lcd_hd44780_4_1.jal
16f72716f727_lcd_hd44780_4_4.jal
16f72716f727_lcd_hd44780_8_4.jal
16f72716f727_lcd_hd44780_8_1.jal
16f7716f77_adc_lowres.jal
16f81916f819_blink_intosc.jal
16f81916f819_lcd_hd44780_4_1.jal
16f81916f819_lcd_hd44780_4_4.jal
16f876a16f876a_lcd_hd44780_4_1.jal
16f876a16f876a_lcd_hd44780_4_4.jal
16f876a16f876a_adc.jal
16f876a16f876a_sht.jal
16f876a16f876a_rtc_lcd.jal
16f87716f877_pata_hard_disk.jal
16f87716f877_sd_card.jal
16f87716f877_adc.jal
16f877a16f877a_lcd_format.jal
16f877a16f877a_seven_segment.jal
16f877a16f877a_i2c_hw_l1.jal
16f877a16f877a_serial_print.jal
16f877a16f877a_i2c_hw_l0.jal
16f877a16f877a_serial_format.jal
16f877a16f877a_random.jal
16f877a16f877a_lcd_hd44780_4_1.jal
16f877a16f877a_lcd_hd44780_8_1.jal
16f877a16f877a_lcd_hd44780_8_4.jal
16f877a16f877a_serial_hw_int_cts.jal
16f877a16f877a_i2c_sw_l1.jal
16f877a16f877a_serial_hardware.jal
16f877a16f877a_backlight.jal
16f877a16f877a_rtc_lcd.jal
16f877a16f877a_print_serial_numbers.jal
16f877a16f877a_lcd_hd44780_4_4.jal
16f8816f88_lcd_hd44780_4_4.jal
16f8816f88_delay_basic.jal
16f8816f88_random.jal
16f8816f88_backlight.jal
16f8816f88_lcd_hd44780_4_1.jal
16f8816f88_print_serial_numbers.jal
16f8816f88_adc_lowres.jal
16f8816f88_serial_hardware.jal
16f8816f88_i2c_sw_l1.jal
16f8816f88_adc_highres.jal
16f8816f88_serial_print.jal
16f8816f88_serial_hw_int_cts.jal
16f88616f886_pwm_adc_freq.jal
16f88616f886_rtc_lcd_20mhz.jal
16f88616f886_math.jal
16f88616f886_pwm_adc_res.jal
16f88716f887_lcd_hd44780_8_4.jal
16f88716f887_lcd_hd44780_8_1.jal
16f88716f887_lcd_hd44780_4_1.jal
16f88716f887_lcd_hd44780_4_4.jal
18f123018f1230_lcd_hd44780_4_1.jal
18f14k5018f14k50_serial_hw_int_cts.jal
18f14k5018f14k50_usb_serial.jal
18f14k5018f14k50_random.jal
18f14k5018f14k50_usb_hid_mouse.jal
18f14k5018f14k50_i2c_hw_l0.jal
18f14k5018f14k50_i2c_hw_l1.jal
18f14k5018f14k50_i2c_sw_l1.jal
18f14k5018f14k50_usb_hid_keyboard.jal
18f14k5018f14k50_serial_format.jal
18f14k5018f14k50_serial_hardware.jal
18f14k5018f14k50_usb_hid_generic.jal
18f14k5018f14k50_sqrt.jal
18f14k5018f14k50_serial_print.jal
18f232018f2320_lcd_hd44780_4_4.jal
18f232018f2320_lcd_hd44780_4_1.jal
18f245018f2450_usb_hid_mouse.jal
18f245018f2450_usb_serial.jal
18f245018f2450_sqrt.jal
18f245018f2450_usb_hid_keyboard.jal
18f245018f2450_usb_hid_generic.jal
18f245018f2450_serial_hardware.jal
18f245018f2450_serial_print.jal
18f245018f2450_random.jal
18f245018f2450_serial_hw_int_cts.jal
18f245018f2450_serial_format.jal
18f245018f2450_i2c_sw_l1.jal
18f45218f452_pata_hard_disk.jal
18f45218f452_sd_card.jal
18f455018f4550_i2c_hw_l1.jal
18f455018f4550_i2c_hw_l0.jal
18f455018f4550_i2c_sw_l1.jal
18f455018f4550_usb_hid_keyboard.jal
18f455018f4550_serial_hw_int_cts.jal
18f455018f4550_serial_format.jal
18f455018f4550_sqrt.jal
18f455018f4550_usb_hid_generic.jal
18f455018f4550_usb_hid_mouse.jal
18f455018f4550_serial_print.jal
18f455018f4550_usb_serial.jal
18f455018f4550_seven_segment.jal
18f455018f4550_serial_hardware.jal
18f455018f4550_random.jal
18f468518f4685_lcd_hd44780_8_4.jal
18f468518f4685_lcd_hd44780_8_1.jal
18f468518f4685_lcd_hd44780_4_4.jal
18f468518f4685_lcd_hd44780_4_1.jal
18f631018f6310_lcd_hd44780_4_4.jal
18f631018f6310_lcd_hd44780_8_4.jal
18f631018f6310_lcd_hd44780_8_8.jal
18f631018f6310_lcd_hd44780_4_1.jal
18f631018f6310_lcd_hd44780_8_1.jal



eeprom_24lc256

24LC256 i2c eeprom library

Author Matthew Schinkel, copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4m

Description

read and write to 24lc256 i2c eeprom


Sources

http://groups.google.com/group/jallib


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

18f45218f452_24lc256.jal



fat32

FAT32 library for reading fat32 filesystem (beta version)

Author Matthew Schinkel, copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4k

Description

this library reads files & folders from a fat32 formatted media
             such as sd cards & hard disks. BETA VERSION!


Sources

http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx
http://www.pjrc.com/tech/8051/ide/fat32.html
http://en.wikipedia.org/wiki/File_Allocation_Table


Notes

This lib does not create filename's on fat32 partitions, although it may
in the future. Please see this article http://www.desktoplinux.com/news/NS4980952387.html?kc=rss
before you think about implementing writing of filenames into your project.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

Private

Functions


Related samples

Here are the list of samples which use this library:

18f45218f452_fat32_sd_card.jal
18f45218f452_fat32_pata_hard_disk.jal



format

Writes formatted values to output device

Author Stef Mientki, Copyright (c) 2002 .. 2006, all rights reserved.
Adapted-by Joep Suijs, Albert Faber, Eur van Andel
Compiler >=2.2

Description

Outputs variables to output device.
Writes formatted signed/unsiged bytes/words to the specified output device.
Decimal (with fraction), Hex and Time formats available.


  
Example:


     
var sword BHL = -684


     
; send the signed word to the LCD display
; total field width 6 chars, including sign and decimal
; with 2 digits behind the decimal point
format_sword_dec(LCD_char,BHL,6,2)


     
; and now send the same signed word to the serial port
format_sword_dec(Serial_HW_data,BHL,6,2)  


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

Private

Functions


Related samples

Here are the list of samples which use this library:

16f648a16f648a_serial_print.jal
16f648a16f648a_serial_format.jal
16f72316f723_serial_print.jal
16f72316f723_serial_format.jal
16f876a16f876a_sht.jal
16f876a16f876a_rtc_lcd.jal
16f876a16f876a_tc77.jal
16f877a16f877a_print_serial_numbers.jal
16f877a16f877a_lcd_format.jal
16f877a16f877a_rtc_lcd.jal
16f877a16f877a_serial_format.jal
16f877a16f877a_serial_print.jal
16f8816f88_print_serial_numbers.jal
16f8816f88_serial_print.jal
16f88616f886_rtc_lcd_4mhz.jal
16f88616f886_pwm_adc_freq.jal
16f88616f886_rtc_lcd_20mhz.jal
16f88616f886_rtc_lcd_125khz.jal
16f88616f886_pwm_adc_res.jal
18f14k5018f14k50_serial_format.jal
18f14k5018f14k50_serial_print.jal
18f245018f2450_serial_format.jal
18f245018f2450_serial_print.jal
18f45218f452_fat32_pata_hard_disk.jal
18f45218f452_fat32_sd_card.jal
18f455018f4550_serial_format.jal
18f455018f4550_serial_print.jal



humidity_sht

SHTxx, for Sensirion humidity and temperature sensors

Author Eur van Andel, eur@fiwihex.nl Copyright (c) 2008
Adapted-by
Compiler =2.4h

Description

The Sensirion SHT1x/SHT7x is a single chip relative humidity and
temperature multi sensor module comprising a calibrated digital output.
It comes in 5 flavors, with different accuracy and package style:
sensor   hum acc  temp acc    package
SHT10    4.5%     0.5C        SMD (LCC)
SHT11    3.0%     0.4C        SMD (LCC) 
SHT15    2.0%     0.3C        SMD (LCC) 
SHT71    3.0%     0.4C        4-pin single-in-line 
SHT75    1.8%     0.3C        4-pin single-in-line 
all consist of the same silicon: the less accurate models are sold cheaper.
My experience is mixed: I've seen some consistent +2C offset in temperature,
but good humidty measurements. The 4-pin package breaks when you touch it.
The SMD package has naked tracks underneath: you can't route under it!
If exposed to >95% RH for 10 minutes, these sensors will go beserk and need 
<60% RH for an hour to recover. You might try heating them. 
protocol is close to I2C, but not the same. Remember to pull up DATA.
0b0000_0011  starts temperature measurement
0b0000_0101  starts humidity measurement
device returns three bytes: MSB, LSB and CRC
this library doesn't perform any CRC check


Sources

http://www.sensirion.com/en/01_humidity_sensors/00_humidity_sensors.htm


Dependencies


Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • read_raw_hum_sht(byte out MSB, byte out LSB, byte out CRC)

    read raw 12-bit humidity from SHT
    default value of resolution bit is 12 bit RH
    SHT takes 55 ms for measurement @ 12 bits
    we will wait 70 ms
    SHT may only be switched on for 10% of the time because of self-heating
    so this measurement can only happen every 500ms
    

  • read_hum_word_sht(word out hum)

    read humidity from SHT, result in word precision 0.01%RH
    SHT may only be switched on for 10% of the time because of self-heating
    so this measurement can only happen every 500ms
    

  • sht_get_data(byte out x)

    receive one byte from the SHT
    

  • sht_start()

    send start
          _____         ________ 
    DATA:      |_______| 
              ___     ___ 
    SCK : ___|   |___|   |______ 
    

  • sht_put_ack()

    send ACK
    

  • sht_conn_reset()

    reset SHT interface, must be followed with sht_start and command
    

  • sht_wait_ack()

    pretend to wait for ACK
    

  • sht_reset()

    reset SHT
    

  • read_centicelsius_temp_sht(sword out centicelsius)

    read Celcius temperature from SHT
    with 0.01 C resolution, result is sword type, so -327.68 .. +327.68 C
    SHT takes 320 ms for measurement @ 14 bits
    we will wait 400 ms
    SHT may only be switched on for 10% of the time because of self-heating
    so this measurement can only happen every four seconds!
    

  • sht_put_data(byte in x)

    send one byte to the SHT
    

  • read_celsius_temp_sht(sbyte out celsius)

    read Celcius temperature from SHT
    with 1 C resolution, result is sbyte type, so -126...+127C
    SHT takes 320 ms for measurement @ 14 bits
    we will wait 400 ms
    SHT may only be switched on for 10% of the time because of self-heating
    so this measurement can only happen every four seconds!
    

  • read_hum_sht(byte out hum)

    read humidity from SHT, result in byte precision 1%RH
    SHT may only be switched on for 10% of the time because of self-heating
    so this measurement can only happen every 500ms
    

  • read_raw_temp_sht(byte out MSB, byte out LSB, byte out CRC)

    read raw 14-bit temperature from SHT
    default value of resolution bit is 14 bit temperature
    SHT takes 320 ms for measurement @ 14 bits
    we will wait 400 ms
    SHT may only be switched on for 10% of the time because of self-heating
    so this measurement can only happen every two seconds!
    

Functions


Related samples

Here are the list of samples which use this library:

16f876a16f876a_sht.jal



i2c_hardware

i2c_hardware

Author Stef Mientki, Copyright (C) 2005 Stef Mientki
Adapted-by Joep Suijs, Albert Faber
Compiler >=2.4g

Description

Hardware implementation of I2C (single) master.





 Define i2c pins like:
alias i2c_scl            is pin_c3  ; optional, but good habit ;)
alias i2c_scl_direction  is pin_c3_direction
alias i2c_sda            is pin_c4  ; optional, but good habit ;)
alias i2c_sda_direction  is pin_c4_direction



const word _i2c_bus_speed = 1 ; * 100kHz
const bit _i2c_level = true   ; i2c levels (not SMB)


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • i2c_restart()

    i2c_restart - Sends Restart bit and waits untill finished
    
    

  • i2c_initialize()

    if the device has changed, change the speed if necessary
    
    

  • i2c_stop()

    i2c_stop - Sends Stop bit and waits until finished
    
    

  • i2c_start()

    i2c_start - Sends Start bit and waits untill finished
    
    

Functions

  • i2c_receive_byte(bit in ACK ) return byte

    i2c_receive_byte -
    
    start receiving of a byte and waits till finished
    if param ACK is true, the byte is acknowledged and next bytes can be received.
    if param ACK is false, the byte is nacked and a stop *should be* sent.
    note: this behavior is inverted from the line level and orignal library, but
          consistent with the i2c_software library.
    
    

  • i2c_transmit_byte(byte in data) return bit

    i2c_transmit_byte -
    
    
    


Related samples

Here are the list of samples which use this library:

16f877a16f877a_i2c_hw_l0.jal
16f877a16f877a_i2c_hw_l1.jal
18f14k5018f14k50_i2c_hw_l1.jal
18f14k5018f14k50_i2c_hw_l0.jal
18f455018f4550_i2c_hw_l1.jal
18f455018f4550_i2c_hw_l0.jal



i2c_hw_slave

i2c_hardware slave procedures

Author Sebastien Lelong, Copyright (c) 2008-2009, all rights reserved.
Adapted-by Joep Suijs, Albert Faber
Compiler >=2.4i

Description

Common and useful functions and procedure to implement an I2C slave


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • i2c_hw_slave_init(byte in height_bits_icaddress)

    setup an i2c slave, with low address (not high addresses coded with 10-bits)
    The passed address must be 8-bits long: it's a 7-bits address + the 8th R/W bit
    
    A global "i2c_enable_start_stop_interrupts" constant can be defined to so
    interrupts are generated on Start/Stop signals.
    
    /!\ careful: calling this procedure will enable interrupts (global, peripherals and i2c)
    

  • i2c_hw_slave_write_i2c(byte in what)

    write a byte to i2c bus
    

Functions


Related samples

Here are the list of samples which use this library:

16f72316f723_i2c_hw_slave_echo.jal
16f72316f723_i2c_hw_slave_check_bus.jal
16f877a16f877a_i2c_hw_slave_check_bus.jal
16f877a16f877a_i2c_hw_slave_echo.jal
16f8816f88_i2c_hw_slave_echo.jal
16f8816f88_i2c_hw_slave_check_bus.jal
18f14k5018f14k50_i2c_hw_slave_check_bus.jal
18f14k5018f14k50_i2c_hw_slave_echo.jal
18f455018f4550_i2c_hw_slave_check_bus.jal
18f455018f4550_i2c_hw_slave_echo.jal



i2c_hw_slave_isr

i2c hardware slave ISR

Author Sebastien Lelong, Joep Suijs, Copyright (c) 2008-2009, all rights reserved.
Adapted-by Joep Suijs, Albert Faber
Compiler >=2.4i

Description

this library provides an ISR to implement 
a stateful i2c hardware slave. This is a jalv2 implementation of
Microchip Application Note AN734.



According to AN734, there are 5 possible i2c states. During ISR, each
of this states are detected. This ISR provides a standard skeleton to implement
an i2c hardware slaves, while client code must implement several callbacks
the ISR is expecting to call while processing states.



Here there are:
 - procedure i2c_hw_slave_on_state_1(byte in _trash):
      called when i2c address matches (master starts a talk)



 - procedure i2c_hw_slave_on_state_2(byte in rcv):
      called when master is writing a byte. Slave is thus
      receiving this byte. This callback takes this bytes as
      argument



 - procedure i2c_hw_slave_on_state_3():
      called when master wants to read a byte from slave. Thus,
      slave should send a byte (for instance, using i2c_hw_slave_write_i2c
      from i2c_hw_slave.jal library)



 - procedure i2c_hw_slave_on_state_4():
      called when master still wants to read a byte from slave. That is,
      master required to read (state 3) and now still want to read a byte



 - procedure i2c_hw_slave_on_state_5():
      called when master does not want to talk to slave anymore
      usually a good place to reset data or slave's logic



 - procedure i2c_hw_slave_on_error():
      called when something wrong happens. You can do what you want in
      this case, like resetting the PIC, log some information using usart, ...
         => called any cases other than states 1, 2, 3, 4 or 5


Sources

  - AN734: http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en011798


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f72316f723_i2c_hw_slave_echo.jal
16f877a16f877a_i2c_hw_slave_echo.jal
16f8816f88_i2c_hw_slave_echo.jal
18f14k5018f14k50_i2c_hw_slave_echo.jal
18f455018f4550_i2c_hw_slave_echo.jal



i2c_hw_slave_msg

i2c hardware slave Message Interface

Author Sebastien Lelong, Joep Suijs, Copyright (c) 2008-2009, all rights reserved.
Adapted-by
Compiler >=2.4i

Description

this library provides an message interface to i2c hardware slave. 
It relies on the jalv2 implementation of Microchip Application Note AN734.


                                        
The user needs to supply a procedure to process the received message. 
Basically, this i2c slave waits for a full message to arrive. Then it calls 
the user procedure to process the message and (optional) prepare a response.
Subsequently, this lib will pass the response data over to the master, if 
it wants to have them.
See corresponding sample for more details.




Sources

  - AN734: http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=1824&appnote=en011798


Dependencies


Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f72316f723_i2c_hw_slave_eeprom_simulator.jal
16f72316f723_i2c_hw_slave_msg.jal
16f877a16f877a_i2c_hw_slave_eeprom_simulator.jal
16f877a16f877a_i2c_hw_slave_msg.jal
16f8816f88_i2c_hw_slave_msg.jal
16f8816f88_i2c_hw_slave_eeprom_simulator.jal
18f14k5018f14k50_i2c_hw_slave_msg.jal
18f14k5018f14k50_i2c_hw_slave_eeprom_simulator.jal
18f455018f4550_i2c_hw_slave_eeprom_simulator.jal
18f455018f4550_i2c_hw_slave_msg.jal



i2c_level1

i2c_hardware

Author Joep Suijs, Copyright (C) 2008 Joep Suijs
Adapted-by
Compiler >=2.4g

Description

Level1 implementation of I2C (single) master.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f648a16f648a_i2c_sw_l1.jal
16f72316f723_i2c_sw_master_echo.jal
16f72316f723_i2c_sw_master_check_bus.jal
16f72316f723_i2c_sw_l1.jal
16f877a16f877a_i2c_sw_l1.jal
16f877a16f877a_i2c_sw_master_check_bus.jal
16f877a16f877a_i2c_hw_l1.jal
16f877a16f877a_i2c_sw_master_echo.jal
16f8816f88_i2c_sw_master_check_bus.jal
16f8816f88_i2c_sw_l1.jal
16f8816f88_i2c_sw_master_echo.jal
18f14k5018f14k50_i2c_hw_l1.jal
18f14k5018f14k50_i2c_sw_master_check_bus.jal
18f14k5018f14k50_i2c_sw_master_echo.jal
18f14k5018f14k50_i2c_sw_l1.jal
18f245018f2450_i2c_sw_l1.jal
18f245018f2450_i2c_sw_master_check_bus.jal
18f245018f2450_i2c_sw_master_echo.jal
18f455018f4550_i2c_sw_master_echo.jal
18f455018f4550_i2c_hw_l1.jal
18f455018f4550_i2c_sw_master_check_bus.jal
18f455018f4550_i2c_sw_l1.jal



i2c_software

i2c_software

Author Wouter van Ooijen, Copyright (C) 1998, 1999 Wouter van Ooijen
Adapted-by Joep Suijs.
Compiler >=2.4g

Description

Software implementation of I2C (single) master.





 Define i2c pins like:
alias i2c_scl            is pin_c3
alias i2c_scl_direction  is pin_c3_direction
alias i2c_sda            is pin_c4
alias i2c_sda_direction  is pin_c4_direction



const word _i2c_bus_speed = 1 ; * 100kHz
TODO:


Dependencies


Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

  • i2c_initialize()

    i2c_initialize - initialize the software i2c bus
    
    The output latch values are always low,
    the lines are switched open-collector fashion by 
    manipulating the direction registers.
    
    

  • i2c_stop()

    i2c_stop - output a stop condition
    
    
    

  • i2c_start()

    i2c_start - output a start condition
    
    
    

  • i2c_restart()

    i2c_restart - output a (re)start condition
    
    A restart is a start without a previous stop.
    This procedure is provided as part of the API to maintain compatibility 
    with the i2c hardware master lib.
    
    

Private
  • _i2c_bit_out(bit in x)

    _i2c_bit_out- output a single bit (for internal use only)
    
    
    

  • _i2c_bit_in(bit out x)

    _i2c_bit_in- input a single bit (for internal use only)
    
    
    

  • _i2c_wait()

    _i2c_wait - wait for a change to settle (for internal use only)
    
    The delay is determined by i2c_bus_speed and is 1/4 of the cycle time.
    Given the delay resolution of 1 us and all actions required by 
    i2c_software routines, the actual bus speed will be lower then the
    configured maximum.
    
    


Functions

  • i2c_receive_byte( bit in ack) return byte

    i2c_receive_byte - read one byte
    
    The ACK flag indicated if the byte read must be acked.
    In general, all bytes read by the master are acked, except the last one.
    Failing to NACK the last byte read will give unpredictable results.
    (Often it will provide repeatable sequences, where one out of 2 to 4 of 
    the reads from a specific device is correct. You are warned!)
    
    

  • i2c_transmit_byte( byte in x ) return bit

    i2c_transmit_byte - output one byte
    
    
    


Related samples

Here are the list of samples which use this library:

16f648a16f648a_i2c_sw_l1.jal
16f72316f723_i2c_sw_master_echo.jal
16f72316f723_i2c_sw_l1.jal
16f72316f723_i2c_sw_master_check_bus.jal
16f877a16f877a_i2c_sw_l1.jal
16f877a16f877a_i2c_sw_master_check_bus.jal
16f877a16f877a_i2c_sw_master_echo.jal
16f8816f88_i2c_sw_master_echo.jal
16f8816f88_i2c_sw_master_check_bus.jal
16f8816f88_i2c_sw_l1.jal
18f14k5018f14k50_i2c_sw_master_check_bus.jal
18f14k5018f14k50_i2c_sw_master_echo.jal
18f14k5018f14k50_i2c_sw_l1.jal
18f245018f2450_i2c_sw_master_echo.jal
18f245018f2450_i2c_sw_l1.jal
18f245018f2450_i2c_sw_master_check_bus.jal
18f45218f452_24lc256.jal
18f455018f4550_i2c_sw_master_echo.jal
18f455018f4550_i2c_sw_master_check_bus.jal
18f455018f4550_i2c_sw_l1.jal



ir_ranger_gp2d02

GP2D02 IR ranger library

Author Sebastien Lelong, Copyright (c) 2008-2009, all rights reserved.
Adapted-by
Compiler >=2.4k

Description

this lib is able to handle the GP2D02 lib, reading distance 
measure with this IR Ranger.



You can either use the read procedure, or access the pseudo-variable
to retrieve distance measures.



When defining pins the ranger is connected to to, it's important to 
set them as "volatile" (level will go low/high within function call)
See sample(s) for more.


Sources

  - datasheet: http://www.datasheetcatalog.org/datasheet/Sharp/mXvryzu.pdf


Notes

reading a distance can take quite a long time, approx. 74ms.
See datasheet for more, but you should remember this while using this IR ranger


Dependencies


Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f8816f88_ir_ranger_gp2d02.jal



jascii

ASCII text character constants and case conversion procedures

Author Wouter van Ooijen, Copyright (c) 1998, all rights reserved.
Adapted-by Joep Suijs, Rob Hamerling
Compiler >=2.4

Description

- ASCII text character constant definitions
             - case conversion procedures toupper and tolower



use of toupper
   var byte char = "b"  -- assign lower case "b" to char
   toupper(char)        -- char now contains "B"


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

No sample found


keyboard

keyboard, scans 4x4 keybaord and returns 0x00..0x0F is keypressed, 0x10 if none pressed

Author Javier Martínez, Copyright (c) 2003, all rights reserved.
Adapted-by Eur van Andel, eur@fiwihex.nl, Joep Suijs
Compiler >=2.4g

Description

This library is used to scan a 4x3 or 4x4 keyboard.
To use it, you need to define three variables:
   keydrive is the half port (_high or _low) with the cols connected.
   keydrive_direction is the related direction register.
   keyscan  is the half port (_high or _low) with the rows connected.



   Example:


   
   var volatile byte keyscan  is porta_low      -- rows of keyboard
   var volatile byte keydrive is portb_low      -- columns of keyboard
   var volatile byte keydrive_direction is portb_low_direction
   include keyboard                                           
Note: if you don't want keyboard.jal change the direction of your pins, make sure all
keydrive pins are set to output before you call the library and define:
   var volatile byte keydrive_direction is keydrive


   
The library has two functions to read the keyboard:
getkey()       returns the key pressed.
getkey_once()  returns a pressed key only once (and 'none', 0x10 until the next key is pressed) 



Hardware setup: connect the keyboard rows to a half port (higher or lower 4 bits of a port)
and connect the cols to a half port. Put a pull-down resistor (10k - 47k) on each row pin.
Adaptation: soldering your wires in the right order is a lot harder than you think. 
Make sure you keep the rows and cols together and connect them to right port.
You could either adapt your wiring to match the default configuration or reconfigure the
library by defining the next 8 constants before you include keyboard.jal, like:
   const row1 = 0b0000_0100 
   const row2 = 0b0000_0001
   const row3 = 0b0000_0010
   const row4 = 0b0000_1000
   const col1 = 0b0000_1000
   const col2 = 0b0000_0010
   const col3 = 0b0000_0100
   const col4 = 0b0000_0001
Connect the keyboard and press the buttons. Adapt the row and column constants so 
pressing the buttons give the right result.
Note: you need to specify all 8 constants, even when you have a 4x3 keyboard. In 
this case you can specify: 
   const col4 = 0b0000_0000



keyboard map (4x4, col4 is left out with 4x3 keyboard)



     1 2 3 A     row1  
     4 5 6 B     row2 
     7 8 9 C     row3 
     * 0 # D     row4 



 col 1 2 3 4


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions

  • getkey() return byte

    getkey - return the key pressed (until it is released) 
    
    return:  0 .. 9      numeric key pressed
             10          *
             11          #
             12 .. 15    ???
             16          no key pressed.
             17          error (more then one key pressed)
    
    

  • getkey_once() return byte

    getkey_once - return the value of a key pressed only once
    
    returns: see getkey()
    
    


Related samples

Here are the list of samples which use this library:

16f876a16f876a_keyboard_lcd.jal
16f877a16f877a_keyboard_lcd.jal



large_array_1

Large Array library

Author Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4l

Description

This is library for creating an array that take up more then
             256 bytes memory. Tested on 18F devices only.


Notes

Supports byte array with up to 2048 entries
Supports word array with up to 1024 entries
Supports dword array with up to 512 entries
Creates an array named large_array_1
Use "alias new_array_name is large_array_1" to rename the array
Small sample of how this lib was created at bottom of lib.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

18f45218f452_large_array.jal



large_array_2

Large Array library

Author Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4l

Description

This is library for creating an array that take up more then
             256 bytes memory. Tested on 18F devices only.


Notes

Supports byte array with up to 2048 entries
Supports word array with up to 1024 entries
Supports dword array with up to 512 entries
Creates an array named large_array_2
Use "alias new_array_name is large_array_2" to rename the array
Small sample of how this lib was created at bottom of lib.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

18f45218f452_fat32_sd_card.jal
18f45218f452_fat32_pata_hard_disk.jal



large_array_3

Large Array library

Author Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4l

Description

This is library for creating an array that take up more then
             256 bytes memory. Tested on 18F devices only.


Notes

Supports byte array with up to 2048 entries
Supports word array with up to 1024 entries
Supports dword array with up to 512 entries
Creates an array named large_array_3
Use "alias new_array_name is large_array_3" to rename the array
Small sample of how this lib was created at bottom of lib.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

No sample found


large_array_4

Large Array library

Author Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4l

Description

This is library for creating an array that take up more then
             256 bytes memory. Tested on 18F devices only.


Notes

Supports byte array with up to 2048 entries
Supports word array with up to 1024 entries
Supports dword array with up to 512 entries
Creates an array named large_array_4
Use "alias new_array_name is large_array_4" to rename the array
Small sample of how this lib was created at bottom of lib.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

No sample found


lcd_backlight

lcd_backlight.jal

Author Joep Suijs, Copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4g

Description

Provides standard interface to backlight of (directly connected) lcd.    
First, setup the pin for the backlight:
   var volatile bit lcd_bl is pin_b0
   pin_b0_direction = output              



If the backlight line is inverted (that is low output turn the backlight on),
you must define:
   const bit lcd_bl_inverted = true



If you want digital backlight (on or off), then you can include this library.
But if you want variable backlight (256 steps from off to on), the pin above 
must be a pwm (ccp) output pin. And you have to tell the library, which pwm:
   const byte lcd_backlight_pwm = 1                                        



now include the library & init it:
   include lcd_backlight
   pwm_backlight_init()        


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f648a16f648a_backlight.jal
16f877a16f877a_backlight.jal
16f8816f88_backlight.jal



lcd_hd44780_4

LCD library for HD44780 compatible LCDs, with 4 bits wide datatransfer

Author Rob Hamerling, Copyright (c) 2008..2009, all rights reserved.
Adapted-by Eur van Andel, Joep Suijs (refactoring)
Compiler >=2.4g

Description

   Nibble interface for HD44780 compatible alphanumeric LCD screens.
.
   Expects: - 2 pins for handshake: 'lcd_rs' and 'lcd_en'
        and
            - 1 port nibble for data: 'lcd_dataport'
        or
            - 4 lines for data: 'lcd_d4' .. 'lcd_d7'
   note:    a 'port nibble' - the lower or higher 4 bits of a port - give
            faster and more compact code then random selected data lines.
.
   Directions for use of this library in application programs
   (in this sequence):
   1. Declare the following constants:
         const byte LCD_ROWS     = 2              -- 1, 2 or 4 lines
         const byte LCD_CHARS    = 16             -- 8, 16 or 20 chars per line
      and variables (aliases):
         var   bit  lcd_en        is  pin_A4      -- trigger
         var   bit  lcd_rs        is  pin_A5      -- cmd/data select
      and variables (aliases):
         var   byte lcd_dataport  is  portA_low   -- 4 data pins
      or
         var   bit  lcd_d4        is  pin_A3      -- databit d4 pin
         var   bit  lcd_d5        is  pin_A1      -- databit d5 pin
         var   bit  lcd_d6        is  pin_C0      -- databit d6 pin
         var   bit  lcd_d7        is  pin_C2      -- databit d7 pin
.
   2. Set the chosen LCD dataport and handshake pins to output:
         pin_A4_direction    = output
         pin_A5_direction    = output
      and
         portA_low_direction = all_output
      or
         pin_A3_direction    = output            -- set data pin as output
         pin_A1_direction    = output            -- set data pin as output
         pin_C0_direction    = output            -- set data pin as output
         pin_C2_direction    = output            -- set data pin as output
.
   3. Include this library.
.
   4. Call lcd_init() to initialize the lcd controller.
.
   Above is an example for a 2x16 LCD.
.
   See hd_44780_common for the LCD API.


Dependencies


Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

  • lcd_init()

    Initialize LCD controller to 4-bit mode
    
    

Private

Functions


Related samples

Here are the list of samples which use this library:

16f648a16f648a_lcd_hd44780_4_4.jal
16f648a16f648a_backlight.jal
16f648a16f648a_lcd_hd44780_4_1.jal
16f67616f676_lcd_hd44780_4_4.jal
16f67616f676_lcd_hd44780_4_1.jal
16f69016f690_lcd_hd44780_4_4.jal
16f69016f690_lcd_hd44780_4_1.jal
16f72616f726_lcd_hd44780_4_4.jal
16f72616f726_lcd_hd44780_4_1.jal
16f72716f727_lcd_hd44780_4_1.jal
16f72716f727_lcd_hd44780_4_4.jal
16f81916f819_lcd_hd44780_4_4.jal
16f81916f819_lcd_hd44780_4_1.jal
16f876a16f876a_keyboard_lcd.jal
16f876a16f876a_t6603.jal
16f876a16f876a_lcd_hd44780_4_1.jal
16f876a16f876a_sht.jal
16f876a16f876a_rtc_lcd.jal
16f876a16f876a_tc77.jal
16f876a16f876a_lcd_hd44780_4_4.jal
16f877a16f877a_lcd_format.jal
16f877a16f877a_co2_t6603.jal
16f877a16f877a_backlight.jal
16f877a16f877a_keyboard_lcd.jal
16f877a16f877a_rtc_lcd.jal
16f877a16f877a_lcd_hd44780_4_1.jal
16f877a16f877a_lcd_hd44780_4_4.jal
16f8816f88_lcd_hd44780_4_1.jal
16f8816f88_lcd_hd44780_4_4.jal
16f8816f88_backlight.jal
16f88616f886_rtc_lcd_4mhz.jal
16f88616f886_rtc_lcd_125khz.jal
16f88616f886_rtc_lcd_20mhz.jal
16f88616f886_pwm_adc_freq.jal
16f88616f886_pwm_adc_res.jal
16f88716f887_lcd_hd44780_4_1.jal
16f88716f887_lcd_hd44780_4_4.jal
18f123018f1230_lcd_hd44780_4_1.jal
18f232018f2320_lcd_hd44780_4_1.jal
18f232018f2320_lcd_hd44780_4_4.jal
18f245018f2450_lcd_hd44780_4.jal
18f455018f4550_lcd_hd44780_4.jal
18f468518f4685_lcd_hd44780_4_1.jal
18f468518f4685_lcd_hd44780_4_4.jal
18f631018f6310_lcd_hd44780_4_4.jal
18f631018f6310_lcd_hd44780_4_1.jal



lcd_hd44780_8

LCD library for HD44780 compatible LCDs, with 8 bits wide datatransfer

Author Rob Hamerling, Copyright (c) 2008..2009, all rights reserved.
Adapted-by Eur van Andel, Joep Suijs (refactoring)
Compiler >=2.4g

Description

   Port interface for HD44780 compatible alphanumeric LCD screens.
   Uses 8 bit wide datapath + 2 handshake lines (total 10 PIC pins).
   Expects: - 2 pins for handshake: 'lcd_rs' and 'lcd_en'
            - 1 complete port for data: 'lcd_dataport'
   or
            - 2 pins for handshake: 'lcd_rs' and 'lcd_en'
            - 8 lines for data: 'lcd_d0' .. 'lcd_d7'
   note:    a 'port nibble' - the lower or higher 4 bits of a port - give
            faster and more compact code then random selected data lines.
.
   Directions for use of this library in application programs
   (in this sequence):
   1. Declare the following constants:
         const byte LCD_ROWS     = 2              -- 1, 2 or 4 lines
         const byte LCD_CHARS    = 16             -- 8, 16 or 20 chars per line
      and variables (aliases):
         var   bit  lcd_rs        is  pin_D2      -- cmd/data select
         var   bit  lcd_en        is  pin_D3      -- trigger
      and variables (aliases):
         var   byte lcd_dataport  is  portF       -- 8 data pins
       or
         var   byte lcd_dataport_low  is portD_high  -- 4 low order data pins
         var   byte lcd_dataport_high is portC_high  -- 4 high order data pins
       or
         var   bit  lcd_d0        is  pin_D0      -- databit d0 pin
         var   bit  lcd_d1        is  pin_D1      -- databit d1 pin
         var   bit  lcd_d2        is  pin_C6      -- databit d2 pin
         var   bit  lcd_d3        is  pin_C7      -- databit d3 pin
         var   bit  lcd_d4        is  pin_B0      -- databit d4 pin
         var   bit  lcd_d5        is  pin_B1      -- databit d5 pin
         var   bit  lcd_d6        is  pin_C0      -- databit d6 pin
         var   bit  lcd_d7        is  pin_C2      -- databit d7 pin
.
   2. Set the chosen LCD handshake pins to output:
         pin_D2_direction     = output
         pin_D3_direction     = output
     and the data port to output:
         portF_direction      = ALL_OUTPUT
     or 2 half data ports to output:
         portD_high_direction = ALL_OUTPUT
         portC_high_direction = ALL_OUTPUT
     or 8 individual pins to outout
         pin_D0_direction     = output -- set data pin as output
         pin_D1_direction     = output -- set data pin as output
         pin_C6_direction     = output -- set data pin as output
         pin_C7_direction     = output -- set data pin as output
         pin_B0_direction     = output -- set data pin as output
         pin_B1_direction     = output -- set data pin as output
         pin_C0_direction     = output -- set data pin as output
         pin_C2_direction     = output -- set data pin as output
.
   3. Include this library.
.
   4. Call lcd_init() to initialize the lcd controller.
.
   Above is an example for a 2x16 LCD.
.
   See hd_44780_common for the LCD API.


Dependencies


Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

  • lcd_init()

    Initialise the LCD controller and API
    
    

Private

Functions


Related samples

Here are the list of samples which use this library:

16f72716f727_lcd_hd44780_8_1.jal
16f72716f727_lcd_hd44780_8_4.jal
16f877a16f877a_lcd_hd44780_8_4.jal
16f877a16f877a_lcd_hd44780_8_1.jal
16f88716f887_lcd_hd44780_8_1.jal
16f88716f887_lcd_hd44780_8_4.jal
18f468518f4685_lcd_hd44780_8_4.jal
18f468518f4685_lcd_hd44780_8_1.jal
18f631018f6310_lcd_hd44780_8_1.jal
18f631018f6310_lcd_hd44780_8_8.jal
18f631018f6310_lcd_hd44780_8_4.jal



lcd_hd44780_common

common library for HD44780 based LCD

Author Richard Zengerink, Copyright (c) 2008..2009, all rights reserved.
Adapted-by Joep Suijs
Compiler >=2.4j

Description

Common API for HD44780 based LCD
.
 Procedures which can be used by application program:
.
* lcd_write_char( byte in value ):
  writes 'value' to lcd
  example: lcd_write_char( "E" )  or lcd_write_char( 69 )
.
* lcd = value:
  writes 'value' to lcd
  example: lcd = "E"  or lcd = 69
.
* lcd_cursor_position(byte in line, byte in pos):
  places the cursor on position (pos) in line (line) (zero based!)
  example: lcd_new_line_cursor_position (1, 8)
.
* lcd_shift_left(byte in value):
  shifts the display [value] times to the left without changing DDRAM data.
  example: lcd_shift_left(4)
  or       lcd_shift_left(variable)
.
* lcd_shift_right(byte in value):
  shifts the display [value] times to the right without changing DDRAM data.
  example: lcd_shift_right(12)
  or       lcd_shift_right(variable)
.
* lcd_cursor_shift_left(byte in value):
  shifts the cursor [value] times to the left without changing display
  contents and DDRAM data.
  example: lcd_cursor_shift_left(8)
  or       lcd_cursor_shift_left(variable)
.
* lcd_cursor_shift_right(byte in value):
  shifts the cursor [value] times to the right without changing display
  contents and DDRAM data.
  example: lcd_cursor_shift_right(3)
  or       lcd_cursor_shift_right(variable)
.
* lcd_clear:
  Write "20H" to DDRAM and set DDRAM address to "00H" from AC
  This will clear the display.
.
* lcd_home:
  Set DDRAM address to "00H" from AC and return cursor to its original
  position if shifted. The contents of DDRAM are not changed.
.
* lcd_cursor_blink_display(bit in cursor,bit in blink,bit in display):
  sets the underline cursor on/off, let the block-cursor blinking/off
  and puts the display on/off
  example: lcd_cursor_blink_display(on,off,on)
.
* lcd_clear_line ( byte in line  )
  clears the line [line] of the lcd including DDRAM data of that line
  example: lcd_clear_line(1)
.
* lcd_progress(byte in line, byte in amount)
  create a progress bar on line [line] with a lenght of [amout]
  example: lcd_progress(2,12)


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Private

Functions

Private

API details

Global variables/contants

Procedures

Private
  • _lcd_restore_cursor()

    _lcd_restore_cursor - sets the cursor to the position in the shadow register
    (this routine is only used inside this file)
    
    

  • _hd44780_init()

    _hd44780_init - Initialise display (not realy internal, but not for users)
    
    This procedure is called from lcd_init of the interface used. lcd_init brings
    up the interface and powers up the display.
    This procedure sets the display in the pre-defined startposition (clear
    screen, no cursor etc).
    
    


Functions

Private

Related samples

No sample found


lcd_hd44780_serial_sw

LCD library for HD44780 compatible LCDs, interfaced with 1 pin (serial_sw)

Author Joep Suijs, Copyright (c) 2008..2009, all rights reserved.
Adapted-by
Compiler >=2.4g

Description

   Software serial interface for HD44780 compatible alphanumeric LCD screens.  
 --
   Directions for use of this library in application programs
   (in this sequence):
   1. Declare the following constants:
         const byte LCD_ROWS     = 2              -- 1, 2 or 4 lines
         const byte LCD_CHARS    = 16             -- 8, 16 or 20 chars per line
      and variables (aliases):
         var bit serial_sw_tx_pin  is  pin_d0     -- pin on which lcd is connected



   2. Set the chosen LCD dataport and handshake pins to output:
         pin_d0_direction = output



   3. Include this library.



   4. Call lcd_init() to initialize the lcd controller.



   Above is an example for a 2x16 LCD, connected to pin d0



   See hd_44780_common for the LCD API.


Dependencies


Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

Private

Functions


Related samples

No sample found


math

math.jal - Collection of mathematical functions.

Author Rob Hamerling, Copyright (c) 2009, all rights reserved.
Adapted-by
Compiler 2.4l

Description

Collection of mathematical routines.


Sources

Several authors.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f88616f886_math.jal
18f14k5018f14k50_sqrt.jal
18f245018f2450_sqrt.jal
18f455018f4550_sqrt.jal



pata_hard_disk

Hard disk library for communicating with parallel ata hard drives

Author Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4k

Description

this library provides functions for pata/ide hard disk drives.


Sources

"connecting ide drives by tilmann reh" - http://www.gaby.de/gide/IDE-TCJ.txt
IDE hardware reference & information document by alex t. ivopol
ATA Attachement with Packet Interface 6 - d1410r3-ATA-ATAPI-6.pdf


Notes

- If you are not using Alternate Status, Digital Output or Drive Address registers
         pins cs1 & cs0 can be saved by connecting these ide pins to cs0-high, cs1-low
         at ide connector. normal operation does not require these pins. Set
         "CONST BYTE PATA_HD_USE_CS0_CS1_PINS = TRUE" if you will be using
         these registers
       - You MUST write full sectors of 512 bytes.
       - this lib does not do error checking


Dependencies


Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f87716f877_pata_hard_disk.jal
18f45218f452_pata_hard_disk.jal
18f45218f452_fat32_pata_hard_disk.jal



pic_data_eeprom

reading/writing of PIC's data EEPROM

Author Stef Mientki, Copyright (c) 2002..2006, all rights reserved.
Adapted-by Sebastien Lelong, Rob Hamerling.
Compiler >=2.4i

Description

Read from or write to EEPROM/data a byte, word or double word.
Available procedures:
  * data_eeprom_read(,)
  * data_eeprom_write(,)
  * data_eeprom_read_word(,)
  * data_eeprom_write_word(,)
  * data_eeprom_read_dword(,)
  * data_eeprom_write_dword(,)
Available functions:
  *  = data_eeprom()
  *  = data_eeprom_word()
  *  = data_eeprom_dword()
In all cases  is a position relative to the beginning of
EEPROM/data memory, thus starts at 0.
Examples of use:
  * Read a byte of EEPROM at offset 7 into x:
        var byte x
        data_eeprom_read(7, x)
  * Read a word from EEPROM at offset 4 into y:
        var word y
        y = data_eeprom_word(4)
  * Write a byte to EEPROM at offset 18:
        data_eeprom_write(18, 0b1111_0000)


Notes

- Write-protect bits in configuration memory may prohibit writing.
- Writing to locations outside the available memory range may have
  unexpected effects!
- Summary of changes
  + Changed byte-offset to word-offset for larger EEPROMs with 18Fs
  + Offset and flags settings for read and write in separate procedure.
  + Moved check for write completed ahead of read and write, for
    performance (ahead of read needed for read back of same offset).
  + added 'pragma inline' to several procedures
  + some other code optimizations
  + added support for PICs with deviating register names, like 'EEDAT'
    or EEDATL in stead of 'EEDATA' and EEADRL in stead of EEADR.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

Private

Functions


Related samples

Here are the list of samples which use this library:

16f648a16f648a_data_eeprom.jal
16f877a16f877a_data_eeprom.jal
16f8816f88_data_eeprom.jal
16f8816f88_remember_me.jal
18f14k5018f14k50_data_eeprom.jal
18f24218f242_data_eeprom.jal
18f262018f2620_data_eeprom.jal
18f45218f452_fat32_pata_hard_disk.jal
18f45218f452_fat32_sd_card.jal
18f455018f4550_data_eeprom.jal



print

Writes variables to output device

Author Joep Suijs, Copyright (c) 2007..2008, all rights reserved.
Adapted-by Joep Suijs
Compiler >=2.2

Description

Outputs variables to output device.
formats: _decimal and _hex
vars:    bit, byte, sbyte, word, sword, dword, sdword


  
Example:


     
var sword BHL = -684


     
; print the signed word to the LCD display
print_sword_dec(LCD_char, BHL)


     
; and now print the same signed word to the serial port
print_sword_dec(Serial_HW_data, BHL)


Dependencies


Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

Private

Functions


Related samples

Here are the list of samples which use this library:

16f648a16f648a_serial_hw_int_cts.jal
16f648a16f648a_serial_print.jal
16f648a16f648a_serial_hardware.jal
16f648a16f648a_i2c_sw_l1.jal
16f648a16f648a_backlight.jal
16f648a16f648a_random.jal
16f72316f723_serial_print.jal
16f72316f723_i2c_hw_slave_msg.jal
16f72316f723_serial_hardware.jal
16f72316f723_random.jal
16f72316f723_serial_hw_int_cts.jal
16f72316f723_i2c_sw_l1.jal
16f72316f723_i2c_hw_slave_eeprom_simulator.jal
16f876a16f876a_keyboard_lcd.jal
16f876a16f876a_adc.jal
16f876a16f876a_t6603.jal
16f876a16f876a_sht.jal
16f876a16f876a_rtc_lcd.jal
16f876a16f876a_tc77.jal
16f87716f877_adc.jal
16f877a16f877a_serial_hardware.jal
16f877a16f877a_i2c_hw_slave_msg.jal
16f877a16f877a_i2c_hw_l1.jal
16f877a16f877a_serial_print.jal
16f877a16f877a_i2c_hw_l0.jal
16f877a16f877a_random.jal
16f877a16f877a_serial_hw_int_cts.jal
16f877a16f877a_keyboard_lcd.jal
16f877a16f877a_i2c_hw_slave_eeprom_simulator.jal
16f877a16f877a_i2c_sw_l1.jal
16f877a16f877a_co2_t6603.jal
16f877a16f877a_backlight.jal
16f877a16f877a_rtc_lcd.jal
16f877a16f877a_print_serial_numbers.jal
16f8816f88_i2c_hw_slave_eeprom_simulator.jal
16f8816f88_backlight.jal
16f8816f88_remember_me.jal
16f8816f88_print_serial_numbers.jal
16f8816f88_adc_lowres.jal
16f8816f88_i2c_hw_slave_msg.jal
16f8816f88_serial_hardware.jal
16f8816f88_serial_hw_int_cts.jal
16f8816f88_serial_print.jal
16f8816f88_i2c_sw_l1.jal
16f8816f88_adc_highres.jal
16f8816f88_random.jal
16f88616f886_rtc_lcd_4mhz.jal
16f88616f886_pwm_adc_freq.jal
16f88616f886_rtc_lcd_125khz.jal
16f88616f886_rtc_lcd_20mhz.jal
16f88616f886_math.jal
16f88616f886_pwm_adc_res.jal
18f14k5018f14k50_serial_hw_int_cts.jal
18f14k5018f14k50_random.jal
18f14k5018f14k50_usb_hid_mouse.jal
18f14k5018f14k50_usb_bootloader_autostart.jal
18f14k5018f14k50_i2c_hw_l0.jal
18f14k5018f14k50_i2c_hw_l1.jal
18f14k5018f14k50_i2c_hw_slave_eeprom_simulator.jal
18f14k5018f14k50_i2c_sw_l1.jal
18f14k5018f14k50_usb_hid_keyboard.jal
18f14k5018f14k50_usb_serial.jal
18f14k5018f14k50_serial_hardware.jal
18f14k5018f14k50_usb_hid_generic.jal
18f14k5018f14k50_sqrt.jal
18f14k5018f14k50_i2c_hw_slave_msg.jal
18f14k5018f14k50_serial_print.jal
18f14k5018f14k50_usb_bootloader.jal
18f245018f2450_usb_hid_mouse.jal
18f245018f2450_usb_serial.jal
18f245018f2450_sqrt.jal
18f245018f2450_usb_hid_keyboard.jal
18f245018f2450_usb_bootloader_autostart.jal
18f245018f2450_serial_hardware.jal
18f245018f2450_serial_print.jal
18f245018f2450_usb_hid_generic.jal
18f245018f2450_lcd_hd44780_4.jal
18f245018f2450_random.jal
18f245018f2450_usb_bootloader.jal
18f245018f2450_serial_hw_int_cts.jal
18f245018f2450_i2c_sw_l1.jal
18f455018f4550_usb_bootloader.jal
18f455018f4550_usb_bootloader_autostart.jal
18f455018f4550_i2c_hw_l1.jal
18f455018f4550_i2c_sw_l1.jal
18f455018f4550_serial_hw_int_cts.jal
18f455018f4550_usb_hid_keyboard.jal
18f455018f4550_sqrt.jal
18f455018f4550_i2c_hw_slave_eeprom_simulator.jal
18f455018f4550_usb_hid_generic.jal
18f455018f4550_usb_hid_mouse.jal
18f455018f4550_usb_serial.jal
18f455018f4550_i2c_hw_slave_msg.jal
18f455018f4550_i2c_hw_l0.jal
18f455018f4550_serial_hardware.jal
18f455018f4550_random.jal
18f455018f4550_serial_print.jal
18f455018f4550_lcd_hd44780_4.jal



profiler

profiler.jal

Author Joep Suijs, Copyright (c) 2009..2009, all rights reserved.
Adapted-by
Compiler >=2.4g

Description

   This library provides procedures to profile code parts.
   Intended for software development, uses timer1.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

18f14k5018f14k50_sqrt.jal
18f245018f2450_sqrt.jal
18f455018f4550_sqrt.jal



pwm_ccp1

hardware PWM control, dedicated to module CCP1

Author Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
Adapted-by Sebastien Lelong, Rob Hamerling.
Compiler 2.4l

Description

Performs PWM operations on the CCP1 module.
This file is automatically included by pwm_hardware.jal
when the target PIC has a CCP1 module.


Notes

1. This is a heavy refactoring of the original pwm_hardware.jal
          (Stef's lib)
       2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171.
          Reduced memory occupation. Added procedure for lowres PWM.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • pwm1_set_percent_dutycycle(byte in percent)

    Set a percentage duty cycle, allowing max 100 PWM steps.
    Allowed range: 0..100
    The duty cycle will be set to the specified percentage of the maximum
    for the current PWM frequency.
    Note: The number of available PWM steps can be lower than 100 with
    (very) high PWM frequencies.
    Note: pin_CCP1_direction should be set to output!
    

  • pwm1_on()

    PWM mode on
    Restore duty cycle from shadow registers
    Note: pin_CCP1_direction should be set to output!
    

  • pwm1_off()

    PWM mode off
    retain duty cycle setting in shadow registers
    

  • pwm1_set_dutycycle_lowres(byte in duty)

    Set dutycycle with 8-bits resolution allowing 255 PWM steps.
    The 'duty' argument is the 8-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<7:2> are the 6 MSbits
    Allowed range: 0..255
    Beware that steps 256..1023 are not available. In other words
    the available PWM range is 25% of the highres procedure.
    This procedure is particularly suitable with higher frequencies
    whereby the PWM resolution is limited to 256 steps or less!
    

  • pwm1_set_dutycycle_highres(word in duty)

    Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
    The 'duty' argument is a (max) 10-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<9:2> are the 8 MSbits
    Allowed range: 0..1023
    Note: pin_CCP1_direction should be set to output!
    

  • pwm1_set_dutycycle(byte in duty)

    Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
    This procedure is equivalent to pwm1_set_dutycycle_highres(), but
    the low order 2 bits of the 10-bits duty cycle are set to 0.
    This means that only every 4th of the available 1023 steps can be selected
    and consequently max 255 PWM steps are available.
    This procedure is for user convenience, allowing to specify an 8 bits
    value for the duty cycle is for many applications satisfactory.
    Calling this procedure will also activate PWM.
    Note: pin_CCP1_direction should be set to output!
    

Functions


Related samples

No sample found


pwm_ccp10

hardware PWM control, dedicated to module CCP10

Author Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
Adapted-by Sebastien Lelong, Rob Hamerling.
Compiler 2.4l

Description

Performs PWM operations on the CCP10 module.
This file is automatically included by pwm_hardware.jal
when the target PIC has a CCP10 module.


Notes

1. This is a heavy refactoring of the original pwm_hardware.jal
          (Stef's lib)
       2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171.
          Reduced memory occupation. Added procedure for lowres PWM.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • pwm10_on()

    PWM mode on
    Restore duty cycle from shadow registers
    Note: pin_CCP10_direction should be set to output!
    

  • pwm10_set_dutycycle_lowres(byte in duty)

    Set dutycycle with 8-bits resolution allowing 255 PWM steps.
    The 'duty' argument is the 8-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<7:2> are the 6 MSbits
    Allowed range: 0..255
    Beware that steps 256..1023 are not available. In other words
    the available PWM range is 25% of the highres procedure.
    This procedure is particularly suitable with higher frequencies
    whereby the PWM resolution is limited to 256 steps or less!
    

  • pwm10_set_dutycycle(byte in duty)

    Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
    This procedure is equivalent to pwm10_set_dutycycle_highres(), but
    the low order 2 bits of the 10-bits duty cycle are set to 0.
    This means that only every 4th of the available 1023 steps can be selected
    and consequently max 255 PWM steps are available.
    This procedure is for user convenience, allowing to specify an 8 bits
    value for the duty cycle is for many applications satisfactory.
    Calling this procedure will also activate PWM.
    Note: pin_CCP10_direction should be set to output!
    

  • pwm10_set_dutycycle_highres(word in duty)

    Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
    The 'duty' argument is a (max) 10-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<9:2> are the 8 MSbits
    Allowed range: 0..1023
    Note: pin_CCP10_direction should be set to output!
    

  • pwm10_set_percent_dutycycle(byte in percent)

    Set a percentage duty cycle, allowing max 100 PWM steps.
    Allowed range: 0..100
    The duty cycle will be set to the specified percentage of the maximum
    for the current PWM frequency.
    Note: The number of available PWM steps can be lower than 100 with
    (very) high PWM frequencies.
    Note: pin_CCP10_direction should be set to output!
    

  • pwm10_off()

    PWM mode off
    retain duty cycle setting in shadow registers
    

Functions


Related samples

No sample found


pwm_ccp2

hardware PWM control, dedicated to module CCP2

Author Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
Adapted-by Sebastien Lelong, Rob Hamerling.
Compiler 2.4l

Description

Performs PWM operations on the CCP2 module.
This file is automatically included by pwm_hardware.jal
when the target PIC has a CCP2 module.


Notes

1. This is a heavy refactoring of the original pwm_hardware.jal
          (Stef's lib)
       2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171.
          Reduced memory occupation. Added procedure for lowres PWM.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • pwm2_set_dutycycle(byte in duty)

    Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
    This procedure is equivalent to pwm2_set_dutycycle_highres(), but
    the low order 2 bits of the 10-bits duty cycle are set to 0.
    This means that only every 4th of the available 1023 steps can be selected
    and consequently max 255 PWM steps are available.
    This procedure is for user convenience, allowing to specify an 8 bits
    value for the duty cycle is for many applications satisfactory.
    Calling this procedure will also activate PWM.
    Note: pin_CCP2_direction should be set to output!
    

  • pwm2_off()

    PWM mode off
    retain duty cycle setting in shadow registers
    

  • pwm2_set_dutycycle_lowres(byte in duty)

    Set dutycycle with 8-bits resolution allowing 255 PWM steps.
    The 'duty' argument is the 8-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<7:2> are the 6 MSbits
    Allowed range: 0..255
    Beware that steps 256..1023 are not available. In other words
    the available PWM range is 25% of the highres procedure.
    This procedure is particularly suitable with higher frequencies
    whereby the PWM resolution is limited to 256 steps or less!
    

  • pwm2_on()

    PWM mode on
    Restore duty cycle from shadow registers
    Note: pin_CCP2_direction should be set to output!
    

  • pwm2_set_dutycycle_highres(word in duty)

    Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
    The 'duty' argument is a (max) 10-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<9:2> are the 8 MSbits
    Allowed range: 0..1023
    Note: pin_CCP2_direction should be set to output!
    

  • pwm2_set_percent_dutycycle(byte in percent)

    Set a percentage duty cycle, allowing max 100 PWM steps.
    Allowed range: 0..100
    The duty cycle will be set to the specified percentage of the maximum
    for the current PWM frequency.
    Note: The number of available PWM steps can be lower than 100 with
    (very) high PWM frequencies.
    Note: pin_CCP2_direction should be set to output!
    

Functions


Related samples

No sample found


pwm_ccp3

hardware PWM control, dedicated to module CCP3

Author Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
Adapted-by Sebastien Lelong, Rob Hamerling.
Compiler 2.4l

Description

Performs PWM operations on the CCP3 module.
This file is automatically included by pwm_hardware.jal
when the target PIC has a CCP3 module.


Notes

1. This is a heavy refactoring of the original pwm_hardware.jal
          (Stef's lib)
       2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171.
          Reduced memory occupation. Added procedure for lowres PWM.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • pwm3_on()

    PWM mode on
    Restore duty cycle from shadow registers
    Note: pin_CCP3_direction should be set to output!
    

  • pwm3_set_dutycycle(byte in duty)

    Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
    This procedure is equivalent to pwm3_set_dutycycle_highres(), but
    the low order 2 bits of the 10-bits duty cycle are set to 0.
    This means that only every 4th of the available 1023 steps can be selected
    and consequently max 255 PWM steps are available.
    This procedure is for user convenience, allowing to specify an 8 bits
    value for the duty cycle is for many applications satisfactory.
    Calling this procedure will also activate PWM.
    Note: pin_CCP3_direction should be set to output!
    

  • pwm3_set_dutycycle_lowres(byte in duty)

    Set dutycycle with 8-bits resolution allowing 255 PWM steps.
    The 'duty' argument is the 8-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<7:2> are the 6 MSbits
    Allowed range: 0..255
    Beware that steps 256..1023 are not available. In other words
    the available PWM range is 25% of the highres procedure.
    This procedure is particularly suitable with higher frequencies
    whereby the PWM resolution is limited to 256 steps or less!
    

  • pwm3_set_dutycycle_highres(word in duty)

    Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
    The 'duty' argument is a (max) 10-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<9:2> are the 8 MSbits
    Allowed range: 0..1023
    Note: pin_CCP3_direction should be set to output!
    

  • pwm3_set_percent_dutycycle(byte in percent)

    Set a percentage duty cycle, allowing max 100 PWM steps.
    Allowed range: 0..100
    The duty cycle will be set to the specified percentage of the maximum
    for the current PWM frequency.
    Note: The number of available PWM steps can be lower than 100 with
    (very) high PWM frequencies.
    Note: pin_CCP3_direction should be set to output!
    

  • pwm3_off()

    PWM mode off
    retain duty cycle setting in shadow registers
    

Functions


Related samples

No sample found


pwm_ccp4

hardware PWM control, dedicated to module CCP4

Author Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
Adapted-by Sebastien Lelong, Rob Hamerling.
Compiler 2.4l

Description

Performs PWM operations on the CCP4 module.
This file is automatically included by pwm_hardware.jal
when the target PIC has a CCP4 module.


Notes

1. This is a heavy refactoring of the original pwm_hardware.jal
          (Stef's lib)
       2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171.
          Reduced memory occupation. Added procedure for lowres PWM.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • pwm4_set_dutycycle_lowres(byte in duty)

    Set dutycycle with 8-bits resolution allowing 255 PWM steps.
    The 'duty' argument is the 8-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<7:2> are the 6 MSbits
    Allowed range: 0..255
    Beware that steps 256..1023 are not available. In other words
    the available PWM range is 25% of the highres procedure.
    This procedure is particularly suitable with higher frequencies
    whereby the PWM resolution is limited to 256 steps or less!
    

  • pwm4_off()

    PWM mode off
    retain duty cycle setting in shadow registers
    

  • pwm4_on()

    PWM mode on
    Restore duty cycle from shadow registers
    Note: pin_CCP4_direction should be set to output!
    

  • pwm4_set_percent_dutycycle(byte in percent)

    Set a percentage duty cycle, allowing max 100 PWM steps.
    Allowed range: 0..100
    The duty cycle will be set to the specified percentage of the maximum
    for the current PWM frequency.
    Note: The number of available PWM steps can be lower than 100 with
    (very) high PWM frequencies.
    Note: pin_CCP4_direction should be set to output!
    

  • pwm4_set_dutycycle(byte in duty)

    Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
    This procedure is equivalent to pwm4_set_dutycycle_highres(), but
    the low order 2 bits of the 10-bits duty cycle are set to 0.
    This means that only every 4th of the available 1023 steps can be selected
    and consequently max 255 PWM steps are available.
    This procedure is for user convenience, allowing to specify an 8 bits
    value for the duty cycle is for many applications satisfactory.
    Calling this procedure will also activate PWM.
    Note: pin_CCP4_direction should be set to output!
    

  • pwm4_set_dutycycle_highres(word in duty)

    Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
    The 'duty' argument is a (max) 10-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<9:2> are the 8 MSbits
    Allowed range: 0..1023
    Note: pin_CCP4_direction should be set to output!
    

Functions


Related samples

No sample found


pwm_ccp5

hardware PWM control, dedicated to module CCP5

Author Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
Adapted-by Sebastien Lelong, Rob Hamerling.
Compiler 2.4l

Description

Performs PWM operations on the CCP5 module.
This file is automatically included by pwm_hardware.jal
when the target PIC has a CCP5 module.


Notes

1. This is a heavy refactoring of the original pwm_hardware.jal
          (Stef's lib)
       2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171.
          Reduced memory occupation. Added procedure for lowres PWM.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • pwm5_set_dutycycle_highres(word in duty)

    Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
    The 'duty' argument is a (max) 10-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<9:2> are the 8 MSbits
    Allowed range: 0..1023
    Note: pin_CCP5_direction should be set to output!
    

  • pwm5_set_dutycycle(byte in duty)

    Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
    This procedure is equivalent to pwm5_set_dutycycle_highres(), but
    the low order 2 bits of the 10-bits duty cycle are set to 0.
    This means that only every 4th of the available 1023 steps can be selected
    and consequently max 255 PWM steps are available.
    This procedure is for user convenience, allowing to specify an 8 bits
    value for the duty cycle is for many applications satisfactory.
    Calling this procedure will also activate PWM.
    Note: pin_CCP5_direction should be set to output!
    

  • pwm5_off()

    PWM mode off
    retain duty cycle setting in shadow registers
    

  • pwm5_set_dutycycle_lowres(byte in duty)

    Set dutycycle with 8-bits resolution allowing 255 PWM steps.
    The 'duty' argument is the 8-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<7:2> are the 6 MSbits
    Allowed range: 0..255
    Beware that steps 256..1023 are not available. In other words
    the available PWM range is 25% of the highres procedure.
    This procedure is particularly suitable with higher frequencies
    whereby the PWM resolution is limited to 256 steps or less!
    

  • pwm5_set_percent_dutycycle(byte in percent)

    Set a percentage duty cycle, allowing max 100 PWM steps.
    Allowed range: 0..100
    The duty cycle will be set to the specified percentage of the maximum
    for the current PWM frequency.
    Note: The number of available PWM steps can be lower than 100 with
    (very) high PWM frequencies.
    Note: pin_CCP5_direction should be set to output!
    

  • pwm5_on()

    PWM mode on
    Restore duty cycle from shadow registers
    Note: pin_CCP5_direction should be set to output!
    

Functions


Related samples

No sample found


pwm_ccp6

hardware PWM control, dedicated to module CCP6

Author Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
Adapted-by Sebastien Lelong, Rob Hamerling.
Compiler 2.4l

Description

Performs PWM operations on the CCP6 module.
This file is automatically included by pwm_hardware.jal
when the target PIC has a CCP6 module.


Notes

1. This is a heavy refactoring of the original pwm_hardware.jal
          (Stef's lib)
       2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171.
          Reduced memory occupation. Added procedure for lowres PWM.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • pwm6_set_dutycycle_highres(word in duty)

    Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
    The 'duty' argument is a (max) 10-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<9:2> are the 8 MSbits
    Allowed range: 0..1023
    Note: pin_CCP6_direction should be set to output!
    

  • pwm6_on()

    PWM mode on
    Restore duty cycle from shadow registers
    Note: pin_CCP6_direction should be set to output!
    

  • pwm6_set_dutycycle_lowres(byte in duty)

    Set dutycycle with 8-bits resolution allowing 255 PWM steps.
    The 'duty' argument is the 8-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<7:2> are the 6 MSbits
    Allowed range: 0..255
    Beware that steps 256..1023 are not available. In other words
    the available PWM range is 25% of the highres procedure.
    This procedure is particularly suitable with higher frequencies
    whereby the PWM resolution is limited to 256 steps or less!
    

  • pwm6_set_dutycycle(byte in duty)

    Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
    This procedure is equivalent to pwm6_set_dutycycle_highres(), but
    the low order 2 bits of the 10-bits duty cycle are set to 0.
    This means that only every 4th of the available 1023 steps can be selected
    and consequently max 255 PWM steps are available.
    This procedure is for user convenience, allowing to specify an 8 bits
    value for the duty cycle is for many applications satisfactory.
    Calling this procedure will also activate PWM.
    Note: pin_CCP6_direction should be set to output!
    

  • pwm6_set_percent_dutycycle(byte in percent)

    Set a percentage duty cycle, allowing max 100 PWM steps.
    Allowed range: 0..100
    The duty cycle will be set to the specified percentage of the maximum
    for the current PWM frequency.
    Note: The number of available PWM steps can be lower than 100 with
    (very) high PWM frequencies.
    Note: pin_CCP6_direction should be set to output!
    

  • pwm6_off()

    PWM mode off
    retain duty cycle setting in shadow registers
    

Functions


Related samples

No sample found


pwm_ccp7

hardware PWM control, dedicated to module CCP7

Author Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
Adapted-by Sebastien Lelong, Rob Hamerling.
Compiler 2.4l

Description

Performs PWM operations on the CCP7 module.
This file is automatically included by pwm_hardware.jal
when the target PIC has a CCP7 module.


Notes

1. This is a heavy refactoring of the original pwm_hardware.jal
          (Stef's lib)
       2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171.
          Reduced memory occupation. Added procedure for lowres PWM.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • pwm7_on()

    PWM mode on
    Restore duty cycle from shadow registers
    Note: pin_CCP7_direction should be set to output!
    

  • pwm7_set_dutycycle_lowres(byte in duty)

    Set dutycycle with 8-bits resolution allowing 255 PWM steps.
    The 'duty' argument is the 8-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<7:2> are the 6 MSbits
    Allowed range: 0..255
    Beware that steps 256..1023 are not available. In other words
    the available PWM range is 25% of the highres procedure.
    This procedure is particularly suitable with higher frequencies
    whereby the PWM resolution is limited to 256 steps or less!
    

  • pwm7_set_percent_dutycycle(byte in percent)

    Set a percentage duty cycle, allowing max 100 PWM steps.
    Allowed range: 0..100
    The duty cycle will be set to the specified percentage of the maximum
    for the current PWM frequency.
    Note: The number of available PWM steps can be lower than 100 with
    (very) high PWM frequencies.
    Note: pin_CCP7_direction should be set to output!
    

  • pwm7_off()

    PWM mode off
    retain duty cycle setting in shadow registers
    

  • pwm7_set_dutycycle_highres(word in duty)

    Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
    The 'duty' argument is a (max) 10-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<9:2> are the 8 MSbits
    Allowed range: 0..1023
    Note: pin_CCP7_direction should be set to output!
    

  • pwm7_set_dutycycle(byte in duty)

    Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
    This procedure is equivalent to pwm7_set_dutycycle_highres(), but
    the low order 2 bits of the 10-bits duty cycle are set to 0.
    This means that only every 4th of the available 1023 steps can be selected
    and consequently max 255 PWM steps are available.
    This procedure is for user convenience, allowing to specify an 8 bits
    value for the duty cycle is for many applications satisfactory.
    Calling this procedure will also activate PWM.
    Note: pin_CCP7_direction should be set to output!
    

Functions


Related samples

No sample found


pwm_ccp8

hardware PWM control, dedicated to module CCP8

Author Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
Adapted-by Sebastien Lelong, Rob Hamerling.
Compiler 2.4l

Description

Performs PWM operations on the CCP8 module.
This file is automatically included by pwm_hardware.jal
when the target PIC has a CCP8 module.


Notes

1. This is a heavy refactoring of the original pwm_hardware.jal
          (Stef's lib)
       2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171.
          Reduced memory occupation. Added procedure for lowres PWM.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • pwm8_set_dutycycle(byte in duty)

    Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
    This procedure is equivalent to pwm8_set_dutycycle_highres(), but
    the low order 2 bits of the 10-bits duty cycle are set to 0.
    This means that only every 4th of the available 1023 steps can be selected
    and consequently max 255 PWM steps are available.
    This procedure is for user convenience, allowing to specify an 8 bits
    value for the duty cycle is for many applications satisfactory.
    Calling this procedure will also activate PWM.
    Note: pin_CCP8_direction should be set to output!
    

  • pwm8_off()

    PWM mode off
    retain duty cycle setting in shadow registers
    

  • pwm8_on()

    PWM mode on
    Restore duty cycle from shadow registers
    Note: pin_CCP8_direction should be set to output!
    

  • pwm8_set_dutycycle_lowres(byte in duty)

    Set dutycycle with 8-bits resolution allowing 255 PWM steps.
    The 'duty' argument is the 8-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<7:2> are the 6 MSbits
    Allowed range: 0..255
    Beware that steps 256..1023 are not available. In other words
    the available PWM range is 25% of the highres procedure.
    This procedure is particularly suitable with higher frequencies
    whereby the PWM resolution is limited to 256 steps or less!
    

  • pwm8_set_dutycycle_highres(word in duty)

    Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
    The 'duty' argument is a (max) 10-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<9:2> are the 8 MSbits
    Allowed range: 0..1023
    Note: pin_CCP8_direction should be set to output!
    

  • pwm8_set_percent_dutycycle(byte in percent)

    Set a percentage duty cycle, allowing max 100 PWM steps.
    Allowed range: 0..100
    The duty cycle will be set to the specified percentage of the maximum
    for the current PWM frequency.
    Note: The number of available PWM steps can be lower than 100 with
    (very) high PWM frequencies.
    Note: pin_CCP8_direction should be set to output!
    

Functions


Related samples

No sample found


pwm_ccp9

hardware PWM control, dedicated to module CCP9

Author Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
Adapted-by Sebastien Lelong, Rob Hamerling.
Compiler 2.4l

Description

Performs PWM operations on the CCP9 module.
This file is automatically included by pwm_hardware.jal
when the target PIC has a CCP9 module.


Notes

1. This is a heavy refactoring of the original pwm_hardware.jal
          (Stef's lib)
       2. Partly rewritten for JalV2 version 2.4l and Jallib revision 1171.
          Reduced memory occupation. Added procedure for lowres PWM.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • pwm9_set_dutycycle(byte in duty)

    Set dutycycle for 10-bits resolution but allowing only 255 PWM steps.
    This procedure is equivalent to pwm9_set_dutycycle_highres(), but
    the low order 2 bits of the 10-bits duty cycle are set to 0.
    This means that only every 4th of the available 1023 steps can be selected
    and consequently max 255 PWM steps are available.
    This procedure is for user convenience, allowing to specify an 8 bits
    value for the duty cycle is for many applications satisfactory.
    Calling this procedure will also activate PWM.
    Note: pin_CCP9_direction should be set to output!
    

  • pwm9_set_percent_dutycycle(byte in percent)

    Set a percentage duty cycle, allowing max 100 PWM steps.
    Allowed range: 0..100
    The duty cycle will be set to the specified percentage of the maximum
    for the current PWM frequency.
    Note: The number of available PWM steps can be lower than 100 with
    (very) high PWM frequencies.
    Note: pin_CCP9_direction should be set to output!
    

  • pwm9_set_dutycycle_highres(word in duty)

    Set dutycycle with 10-bits resolution, allowing 1024 PWM steps.
    The 'duty' argument is a (max) 10-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<9:2> are the 8 MSbits
    Allowed range: 0..1023
    Note: pin_CCP9_direction should be set to output!
    

  • pwm9_on()

    PWM mode on
    Restore duty cycle from shadow registers
    Note: pin_CCP9_direction should be set to output!
    

  • pwm9_off()

    PWM mode off
    retain duty cycle setting in shadow registers
    

  • pwm9_set_dutycycle_lowres(byte in duty)

    Set dutycycle with 8-bits resolution allowing 255 PWM steps.
    The 'duty' argument is the 8-bits absolute value for the duty cycle:
     * duty<1:0> are the 2 LSbits
     * duty<7:2> are the 6 MSbits
    Allowed range: 0..255
    Beware that steps 256..1023 are not available. In other words
    the available PWM range is 25% of the highres procedure.
    This procedure is particularly suitable with higher frequencies
    whereby the PWM resolution is limited to 256 steps or less!
    

Functions


Related samples

No sample found


pwm_common

Hardware PWM control, common procedures

Author Stef Mientki, Copyright (C) 2002-2006, all rights reserved.
Adapted-by Sebastien Lelong
Compiler 2.4l

Description

This lib handles common operations on PWM, regardless the channel number.
It is used in combination with one or more pwm_ccp libraries
(eg. pwm_ccp1.jal, pwm_ccp2.jal, etc.). These libraries are included
automatically dependent of the configuration of the target PIC.


Notes

This is a heavy refactoring of the original pwm_hardware.jal (Stef's lib).


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • pwm_max_resolution(byte in prescaler)

    Sets all(!) CCP modules for max (10-bits) PWM resolution.
    While setting maximum resolution, the Timer2 prescaler can be used to adjust
    frequency to a some extent with the Timer2 parameter value which can be either:
      * 1 : high frequency
      * 4 : medium frequency
      * 16: low frequency
    
    Below a table showing the PWM frequencies for common clock speeds and
    different Timer2 prescaler values.
    
    ||*Timer2 prescaler* ||  *4MHz*  ||  *8MHz*  || *10MHz*  ||  *20MHz*  ||
    ||    1              || 3.90 kHz || 7.81 kHz || 9.77 kHz || 19.43 kHz ||
    ||    4              ||  976  Hz || 1.95 kHz || 2.44 kHz ||  4.88 kHz ||
    ||    16             ||  244  Hz ||  488  Hz ||  610 Hz  ||  1.22 kHz ||
    
    For PICs with more than one CCP module you should realize that all CCP
    modules use Timer2 and PR2 for PWM operations. This means that the PWM
    period (frequency) of all PWM output pins is the same. Only the duty
    cycle can vary between one and another PWM pin.
    
    Set PWM to maximum resolution (for all PWM pins!).
    This implies 1 out of 3 specific PWM frequencies, depending on the Timer2
    prescaler value passed with the call. See examples in the table above,
    or use the formula in the datasheet to calculate the resulting frequency.
    

  • pwm_set_frequency(dword in freq)

    Sets all(!) CCP modules for a specific PWM frequency.
    
    The minimum and maximum allowed PWM frequencies depend on the clock speed.
    When specifying a value beyond the limits PWM will not be started.
    
    The chosen frequency may enforce a limit on the PWM resolution (number of steps).
    The application program should not specify a higher value for the duty cycle
    than this limit. When exceeding this limit the dutycycle will probably result
    in a 'weird' value.
    Only the procedure set_dutycycle_percent() is safe in this case, the other
    set_dutycycle procedures use absolute values and are not safe!
    

Functions


Related samples

No sample found


pwm_hardware

Hardware PWM control

Author Sebastien Lelong, Copyright (C) 2008-2009, all rights reserved.
Adapted-by Albert Faber, Rob Hamerling.
Compiler 2.4l

Description

Include this library if you want to use the PWM feature of the CCP module(s).
This library uses conditional compile to selectively include underlying PWM
libraries and number of PWM channels, according to the target PIC configuration.
Ex: - 16f88 has 1 PWM channel: including pwm_hardware will prepare PWM
      for 1 channel (using pwm_ccp1.jal)
    - 16f877 has 2 PWM channels: including pwm_hardware will prepare PWM
      for 2 channels (using pwm_ccp1.jal and pwm_ccp2.jal)
    - etc. for PICs with more CCP modules
Note: All used pin_CCPx_directions should be set to output by the application.



With using the PWM hardware a design choice must be made between desired
PWM frequency and desired PWM resolution (number of possible PWM steps).
Choosing maximum PWM resolution implies a relative low PWM frequency and
vice versa: a high frequency limits the number of available PWM steps.
The figures are dependent on the target clock speed.
Refer to pwm_common, pwm_ccp1, pwm_ccp2 ... etc. documentation to
understand how to use these PWM libraries.


Notes

1. Because the PWM libraries use conditional compilation and the 'alias'
   keyword, at least JalV2 compiler version 2.4l is required.
2. These libraries use the pin alias names as declared in Jallib device
   files since revision 1171, so Jallib release 0.4 is a minimum requirement.
3. Some PICs have extended CCP modules.  These will be handled by these
   PWM libraries as 'classic' CCP modules.


Dependencies


Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

12f68312f683_pwm_adc.jal
16f72316f723_pwm_sound.jal
16f72316f723_pwm_led_highres.jal
16f72316f723_pwm_led.jal
16f76716f767_pwm_adc.jal
16f877a16f877a_pwm_led.jal
16f8816f88_pwm_sound.jal
16f8816f88_ir_ranger_gp2d02.jal
16f8816f88_pwm_led_highres.jal
16f8816f88_pwm_led.jal
16f88616f886_pwm_adc_res.jal
16f88616f886_pwm_adc_freq.jal
18f14k5018f14k50_pwm_sound.jal
18f14k5018f14k50_pwm_led.jal
18f14k5018f14k50_pwm_led_highres.jal
18f245018f2450_pwm_led_highres.jal
18f245018f2450_pwm_sound.jal
18f245018f2450_pwm_led.jal
18f455018f4550_pwm_led_highres.jal
18f455018f4550_pwm_sound.jal
18f455018f4550_pwm_led.jal



queue01

queue01 - fifo queue (number 01 is the template)

Author Joep Suijs, Copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4i

Description

this library provides a (one) byte fifo queue. 
This queue is interrupt-safe in the sense that you can write to the queue from the interrupt and
read from the main program or vice versa without special precautions.
Reading (or writing) from both interrupt and main program might not work properly.



The basic interface is pseudo var:
queue01 = x -- put x into queue; block if queue is full
x = queue01 -- read x from queue; block if queue is empty



non-blocking access to the same queue is provided by
queue01_nb_put()
and
queue01_nb_get()



other methods:
queue01_clear()    -- clear queue (makes queue empty)
queue01_empty()    -- returns true if queue is emtpy (depricated, use queue1_is_empty())
queue01_is_empty() -- returns true if queue is emtpy 
queue01_is_full()  -- returns true if queue is full
queue01_nr_free()  -- returns nr of free places in queue
queue01_nr_used()  -- returns nr of used places in queue


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f72316f723_i2c_hw_slave_eeprom_simulator.jal
16f877a16f877a_i2c_hw_slave_eeprom_simulator.jal
16f8816f88_i2c_hw_slave_eeprom_simulator.jal
18f14k5018f14k50_i2c_hw_slave_eeprom_simulator.jal
18f455018f4550_i2c_hw_slave_eeprom_simulator.jal



queue02

queue02 - fifo queue (number 01 is the template)

Author Joep Suijs, Copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4i

Description

this library provides a (one) byte fifo queue. 
This queue is interrupt-safe in the sense that you can write to the queue from the interrupt and
read from the main program or vice versa without special precautions.
Reading (or writing) from both interrupt and main program might not work properly.



The basic interface is pseudo var:
queue02 = x -- put x into queue; block if queue is full
x = queue02 -- read x from queue; block if queue is empty



non-blocking access to the same queue is provided by
queue02_nb_put()
and
queue02_nb_get()



other methods:
queue02_clear()    -- clear queue (makes queue empty)
queue02_empty()    -- returns true if queue is emtpy (depricated, use queue1_is_empty())
queue02_is_empty() -- returns true if queue is emtpy 
queue02_is_full()  -- returns true if queue is full
queue02_nr_free()  -- returns nr of free places in queue
queue02_nr_used()  -- returns nr of used places in queue


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

No sample found


queue03

queue03 - fifo queue (number 01 is the template)

Author Joep Suijs, Copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4i

Description

this library provides a (one) byte fifo queue. 
This queue is interrupt-safe in the sense that you can write to the queue from the interrupt and
read from the main program or vice versa without special precautions.
Reading (or writing) from both interrupt and main program might not work properly.



The basic interface is pseudo var:
queue03 = x -- put x into queue; block if queue is full
x = queue03 -- read x from queue; block if queue is empty



non-blocking access to the same queue is provided by
queue03_nb_put()
and
queue03_nb_get()



other methods:
queue03_clear()    -- clear queue (makes queue empty)
queue03_empty()    -- returns true if queue is emtpy (depricated, use queue1_is_empty())
queue03_is_empty() -- returns true if queue is emtpy 
queue03_is_full()  -- returns true if queue is full
queue03_nr_free()  -- returns nr of free places in queue
queue03_nr_used()  -- returns nr of used places in queue


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

No sample found


queue04

queue04 - fifo queue (number 01 is the template)

Author Joep Suijs, Copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4i

Description

this library provides a (one) byte fifo queue. 
This queue is interrupt-safe in the sense that you can write to the queue from the interrupt and
read from the main program or vice versa without special precautions.
Reading (or writing) from both interrupt and main program might not work properly.



The basic interface is pseudo var:
queue04 = x -- put x into queue; block if queue is full
x = queue04 -- read x from queue; block if queue is empty



non-blocking access to the same queue is provided by
queue04_nb_put()
and
queue04_nb_get()



other methods:
queue04_clear()    -- clear queue (makes queue empty)
queue04_empty()    -- returns true if queue is emtpy (depricated, use queue1_is_empty())
queue04_is_empty() -- returns true if queue is emtpy 
queue04_is_full()  -- returns true if queue is full
queue04_nr_free()  -- returns nr of free places in queue
queue04_nr_used()  -- returns nr of used places in queue


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

No sample found


random

random

Author Joep Suijs, Copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4i

Description

this library provides a (decent) random function.
The formula is provided by *the* George Marsaglia.
(see http://coding.derkeiler.com/Archive/C_CPP/comp.lang.c/2008-03/msg03691.html) 



/* initialize with any 32-bit seed x and any 32-bit y not 0 */
static unsigned long x=2282008, y=362436069;
#define sK ( x=69069*x+123, y^=y<<13, y^=y>>17, y^=y<<5, x+y )



function random_byte returns an 8-bit random number
function random_word returns a 16-bit random number
functon dice         returns a number from 1 to 6



Note: this library will recreate the same sequence. If this is undesired, assign a
      different (non-zero!) startup-value to -rndx and/or _rndx at startup.



Note2: If you don't care about random quality and want to save a few processor cycles or
       memory bytes, define random_downgrade to select a basic random algorithm.


Sources

Interface Copyright (C) 2005 Stef Mientki


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f648a16f648a_random.jal
16f72316f723_random.jal
16f877a16f877a_random.jal
16f8816f88_random.jal
18f14k5018f14k50_random.jal
18f245018f2450_random.jal
18f455018f4550_random.jal



rtc_isr_tmr0

Real Time Clock running from ISR on TMR0

Author Eur van Andel, Copyright (c) 2003..2008, all rights reserved.
Adapted-by Rob Hamerling
Compiler 2.4l

Description

This Interrupt Service Routine updates the variable seconds
about once per second. The precision is 0.2 ppm, the accuracy depends
on the Xtal used.


Sources

http://www.romanblack.com/one_sec.htm
         http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm


Notes

This is the Bresenham Line Algorithm, invented at IBM in 1962,
which gets an accurate end result by summing the small errors resulting of
taking discrete steps and correcting when the error gets too large. This
means that individual second lengths may show some jitter, but that long-term
timekeeping is accurate. Original assembler by Roman Black.



At 20 MHz, so 200ns/clock, so 5 000 000 clocks/second
Rhe RTC has three bytes: bres_hi, bres_mid, bres_lo
timer 0 runs on internal clock speed and interrupts on overflow
every timer 0 interrupt decreases bres_mid by one.
The  2 000 000 value is added when bres_hi en bres_mid are zero
note that remainder is added to bres_lo, which can overflow in bres_mid
this keeps clock count accurate, although interrupts happen every 256 clock
counts the ISR subtracts 1 from the mid byte. It first checks
the mid byte for zero and borrows a bit from bres_hi if needed.



Required PIC settings: OPTION_REG_PSA = 1
                       OPTION_REG_PS = 0
                       OPTION_REG_T0CS = 0   -- Timer0 on instruction cycle clock


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • RTC()

    No documentation found

Functions


Related samples

Here are the list of samples which use this library:

16f876a16f876a_rtc_lcd.jal
16f877a16f877a_rtc_lcd.jal
16f88616f886_rtc_lcd_4mhz.jal
16f88616f886_rtc_lcd_20mhz.jal
16f88616f886_rtc_lcd_125khz.jal



sd_card

Library for communicating with SD memory cards

Author Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4l

Description

this library provides functions for SD memory cards.


Sources

SanDisk Secure Digital Card - http://www.cs.ucr.edu/~amitra/sdcard/ProdManualSDCardv1.9.pdf
How to use MMC/SDC - http://forums.parallax.com/forums/attach.aspx?a=32012


Notes

This version works with only standard capacity sd cards up to 4gb,
       high capacity up to 32 gb, and Extended Capacity up to 2TB
       may be supported later on.


Dependencies


Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f87716f877_sd_card.jal
18f45218f452_sd_card.jal
18f45218f452_fat32_sd_card.jal



serial_hardware

USART hardware control

Author Stef Mientki, Copyright (c) 2002..2006, all rights reserved.
Adapted-by Sebastien Lelong.
Compiler >=2.4g

Description

USART hardware control.
Routines for sending and receiving through the PIC-usart,
both asynchrone and synchrone are supported.
Baudrate can simply be set through a human constant,
because the baudrate depending registers are calculated by this unit.
Baudrate is calculated, starting at the high baudrate flag,
which will ensure the highest possible accuracy.


Dependencies


Summary

Global variables/contants

Procedures

Functions

Private

API details

Global variables/contants

Procedures

  • serial_hw_data'put(byte in data)

    Here Serial read and write are definied as pseudo variables
    so you use them as normal vars, like
     * wait for character being received,
     * then echo the inverted character
    {{{
    serial_hw_data = ! serial_hw_data
    }}}
    
    these procedures will wait till they can perform their action
    therefore it's better to use to following construct
    {{{
     if charater received, echo the inverted character
    if  serial_hw_data_available then
        serial_hw_data = ! serial_hw_data
    end if
     do other things
    }}}
    
    

  • serial_hw_init()

    Initializes the serial port, calculates baudrate registers.
    

  • serial_hw_write_word(word in data)

    like Serial_H_write, but then with a word as input
    The MSB is outputed first
    

  • serial_hw_write(byte in data)

    serial_hw_write - write char to serial port, blocking
    
    Asynchronuous serial send routine, using the TX pin
    Sends byte X (8 bit with no parity) to the serial port
    First checks (and waits if necessary) if transmit buffer is empty
    
    

  • serial_hw_data_raw'put(byte in data)

    These are real raw procedures, declared as pseudo variables
    the user is totally responsible for testing the transmit/receive
    flag before using these functions
    

  • serial_hw_enable()

    Enables USART
    

  • serial_hw_disable()

    Disables USART so ports can be used (temporary) for other purposes.
    USART can be enabled again by calling serial_hw_enable()
    

Functions

Private
  • _serial_hw_read(byte out data) return bit

    _serial_hw_read - internal use only!
    
    (using this inline function for serial_hw_data'get saves a stack level)
    Returns true if a character was received, otherwise returns false.
    Overrun error flag is cleared.
    
    



Related samples

Here are the list of samples which use this library:

16f648a16f648a_serial_print.jal
16f648a16f648a_serial_format.jal
16f648a16f648a_serial_hardware.jal
16f648a16f648a_i2c_sw_l1.jal
16f648a16f648a_random.jal
16f72316f723_serial_print.jal
16f72316f723_i2c_sw_master_echo.jal
16f72316f723_i2c_hw_slave_msg.jal
16f72316f723_serial_hardware.jal
16f72316f723_random.jal
16f72316f723_i2c_sw_l1.jal
16f72316f723_serial_format.jal
16f72316f723_i2c_hw_slave_eeprom_simulator.jal
16f7716f77_adc_lowres.jal
16f876a16f876a_adc.jal
16f876a16f876a_t6603.jal
16f87716f877_adc.jal
16f87716f877_pata_hard_disk.jal
16f87716f877_23k256.jal
16f87716f877_sd_card.jal
16f877a16f877a_serial_hardware.jal
16f877a16f877a_i2c_hw_slave_msg.jal
16f877a16f877a_i2c_hw_l1.jal
16f877a16f877a_serial_print.jal
16f877a16f877a_i2c_hw_l0.jal
16f877a16f877a_serial_format.jal
16f877a16f877a_random.jal
16f877a16f877a_i2c_hw_slave_eeprom_simulator.jal
16f877a16f877a_i2c_sw_l1.jal
16f877a16f877a_co2_t6603.jal
16f877a16f877a_print_serial_numbers.jal
16f877a16f877a_i2c_sw_master_echo.jal
16f8816f88_i2c_hw_slave_eeprom_simulator.jal
16f8816f88_delay_basic.jal
16f8816f88_serial_hardware.jal
16f8816f88_ir_ranger_gp2d02.jal
16f8816f88_serial_hw_echo.jal
16f8816f88_remember_me.jal
16f8816f88_i2c_sw_master_echo.jal
16f8816f88_print_serial_numbers.jal
16f8816f88_adc_lowres.jal
16f8816f88_i2c_hw_slave_msg.jal
16f8816f88_i2c_sw_l1.jal
16f8816f88_adc_highres.jal
16f8816f88_random.jal
16f8816f88_serial_print.jal
16f88616f886_math.jal
18f14k5018f14k50_i2c_sw_master_echo.jal
18f14k5018f14k50_random.jal
18f14k5018f14k50_usb_hid_mouse.jal
18f14k5018f14k50_usb_bootloader_autostart.jal
18f14k5018f14k50_i2c_hw_l0.jal
18f14k5018f14k50_i2c_hw_l1.jal
18f14k5018f14k50_i2c_hw_slave_eeprom_simulator.jal
18f14k5018f14k50_i2c_sw_l1.jal
18f14k5018f14k50_usb_hid_keyboard.jal
18f14k5018f14k50_serial_format.jal
18f14k5018f14k50_serial_hardware.jal
18f14k5018f14k50_usb_hid_generic.jal
18f14k5018f14k50_sqrt.jal
18f14k5018f14k50_i2c_hw_slave_msg.jal
18f14k5018f14k50_serial_print.jal
18f14k5018f14k50_usb_bootloader.jal
18f245018f2450_usb_hid_mouse.jal
18f245018f2450_sqrt.jal
18f245018f2450_usb_hid_keyboard.jal
18f245018f2450_usb_bootloader_autostart.jal
18f245018f2450_serial_hardware.jal
18f245018f2450_serial_print.jal
18f245018f2450_usb_hid_generic.jal
18f245018f2450_random.jal
18f245018f2450_usb_bootloader.jal
18f245018f2450_i2c_sw_master_echo.jal
18f245018f2450_serial_format.jal
18f245018f2450_i2c_sw_l1.jal
18f45218f452_24lc256.jal
18f45218f452_fat32_pata_hard_disk.jal
18f45218f452_pata_hard_disk.jal
18f45218f452_23k256.jal
18f45218f452_sd_card.jal
18f45218f452_fat32_sd_card.jal
18f45218f452_large_array.jal
18f455018f4550_usb_bootloader.jal
18f455018f4550_usb_bootloader_autostart.jal
18f455018f4550_i2c_hw_l1.jal
18f455018f4550_i2c_sw_l1.jal
18f455018f4550_usb_hid_keyboard.jal
18f455018f4550_i2c_sw_master_echo.jal
18f455018f4550_serial_format.jal
18f455018f4550_sqrt.jal
18f455018f4550_i2c_hw_slave_eeprom_simulator.jal
18f455018f4550_usb_hid_generic.jal
18f455018f4550_usb_hid_mouse.jal
18f455018f4550_serial_print.jal
18f455018f4550_i2c_hw_slave_msg.jal
18f455018f4550_i2c_hw_l0.jal
18f455018f4550_serial_hardware.jal
18f455018f4550_random.jal



serial_hw_int_cts

serial_hw_int_cts.jal. Interrupt driven buffered serial interface with flow control.

Author Rob Hamerling, Copyright (c) 2008..2009, all rights reserved.
Adapted-by Joep Suijs
Compiler =2.4h

Description

Serial communications:
  - receive and transmit data transfer is interrupt driven
  - receive and transmit data transfer uses circular buffers
  - automatic CTS flow control with spare free space for FiFo buffer


Notes

 - For data transmit and receive the pins TX and RX are used
   automatically, these have not to be assigned by the application.
 - The selection of the CTS pin above is an example, any other pin
   which is configurable for output can be used.
 - When CTS flow control is not desired then assign serial_ctsinv
   to a dummy bit, for example:
       var  bit  dummy_cts_bit
       alias serial_ctsinv  is  dummy_cts_bit
 - The serial_overflow_discard flag may be dynamically changed
   (depending on how important the data is for the receiving party).
 - Do not touch the following interrupt bits: TXIE, RCIE, PEIE and GIE


Dependencies


Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

Private

Functions

  • serial_hw_read(byte out data) return bit

     Return byte (if any) from circular receive buffer for UART
    
     input:   nothing
    
     output:  received byte (if any)
    
     returns: TRUE  when byte returned
              FALSE if no byte available
    
     notes: - Sets CTS high when receive buffer has more than 
              bytes free space after delivering byte to caller.
    
    
    

  • serial_hw_data'get() return byte

    Return next received byte
    

  • serial_receive_byte(byte out data) return bit

    Deprecated
    

  • serial_send_byte(byte in data) return byte

     Put a single byte in circular transmit buffer for UART
    
     input:   byte to transmit
    
     returns: transmitted byte (or 0x00 when data discarded)
    
     notes: - Activates transmit interrupt handler when data buffered
            - When buffer full act as indicated in 'serial_overflow_discard'
              * TRUE:  discard data
                       (and return 0x00 as data byte)
              * FALSE: wait for free buffer space
                       (returns only after data has been stored in buffer)
    
    
    


Related samples

Here are the list of samples which use this library:

16f648a16f648a_serial_hw_int_cts.jal
16f72316f723_serial_hw_int_cts.jal
16f877a16f877a_serial_hw_int_cts.jal
16f8816f88_serial_hw_int_cts.jal
16f8816f88_serial_hw_int_cts_echo.jal
18f14k5018f14k50_serial_hw_int_cts.jal
18f245018f2450_serial_hw_int_cts.jal
18f455018f4550_serial_hw_int_cts.jal



serial_software

Software RS232 library

Author Stef Mientki, Copyright (c) 2002..2006, all rights reserved.
Adapted-by Sebastien Lelong, Albert Faber
Compiler >=2.4l

Description

software RS232 library
Library supports software RS232 send and receive procedure on any IO-pin.
Both the inverted and non-inverted routines are available, 
so it should fit any hardware.
Baudrate can be set between 110 and 230_400 (for 20 Mhz Xtal),
for lower Xtal frequencies the maximum baudrate will be equally lower.
Baudrates are optimized, so even the high baudrates shouldn't be a problem
(my [Stef] standard = 115_200 Baud, which has never given me any problems).
Interrupts are disabled during transmissions.
Transmission parameters are 8 databits, 2 stopbits, no parity, no handshake.
const serial_sw_stopbits = 1 ; setup for one stopbit.                                                


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

  • serial_sw_data'put(byte in data)

    Here the serial_sw_write procedure is declared as a pseudo variable
    so you can use it in the following way:
    {{{
       serial_sw_write = 0x33
    }}}
    

  • serial_sw_write(byte in data)

    Waits untill a character is received.
    Interrupts will be disabled during this routine, but restored afterwards.
    Also here the code is doubled (inverting and non-inverting)
    and selection is done by a compiler-directive.
    

  • serial_sw_init()

    No documentation found

  • serial_sw_read_wait(byte out data)

    Waits untill a character is received.
    Interrupts will be disabled during this routine, but restored afterwards.
    Also here the code is doubled (inverting and non-inverting)
    and selection is done by a compiler-directive.
    

Functions

  • serial_sw_data'get() return byte

    Here the serial_sw_read_wait procedure is declared as a pseudo variable
    so you can use it in the following way
    {{{
       Data = serial_sw_write
    }}}
    

  • serial_sw_read(byte out data) return bit

    Waits untill a character is received or time out is reached.
    Interrupts will be disabled during this routine, but restored afterwards.
    Also here the code is doubled (inverting and non-inverting)
    and selection is done by a compiler-directive.
    


Related samples

Here are the list of samples which use this library:

16f8816f88_serial_sw_echo.jal



seven_segment

seven_segment.jal - translation routine for 7 segment display

Author Wouter van Ooijen (c) 1998, all rights reserved.
Adapted-by Joep Suijs, Vasile Surducan 25.08.2009
Compiler >=2.2

Description

Translation routine for 7 segment display. 


                                                             
The seven segment display needs to be connected to a single port.
Define the pin layout of the seven segment display like:





 constant for the segments      gfe dcba
const byte seven_segment_a  = 0b_0000_0001
const byte seven_segment_b  = 0b_0000_0010
const byte seven_segment_c  = 0b_0000_0100
const byte seven_segment_d  = 0b_0000_1000
const byte seven_segment_e  = 0b_0001_0000
const byte seven_segment_f  = 0b_0010_0000
const byte seven_segment_g  = 0b_0100_0000
const byte seven_segment_dp = 0b_1000_0000   



character set:



value 0 is character 0     
value 1 is character 1     
value 2 is character 2     
value 3 is character 3     
value 4 is character 4     
value 5 is character 5     
value 6 is character 6     
value 7 is character 7     
value 8 is character 8     
value 9 is character 9     
value 10 is character A    
value 11 is character b    
value 12 is character C_big
value 13 is character d    
value 14 is character E    
value 15 is character F    
value 16 is character S    
value 17 is character c_small
value 18 is character r    
value 19 is character H    
value 20 is character i_small
value 21 is character L    
value 22 is character o    
value 23 is character P    
value 24 is character U_big
value 26 is character u    
value 27 is character space



Use:  



const bit seven_segment_common_anode = true ; omit this line if you use a common cathode display.



portd_direction = all_output
portd = seven_from_digit(1) -- display '1'


    


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f877a16f877a_seven_segment.jal
18f455018f4550_seven_segment.jal



spi_master_hw

SPI Master (spi_master_hw.jal)

Author William Welch Copyright (c) 2009, all rights reserved.
Adapted-by
Compiler 2.4l

Description

SPI Master hardware control.
Routines for sending and receiving through the SPI in master mode


Sources

good overview of SPI at http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus
also at: http://elm-chan.org/docs/spi_e.html


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f87716f877_23k256.jal
16f87716f877_sd_card.jal
18f45218f452_sd_card.jal
18f45218f452_fat32_pata_hard_disk.jal
18f45218f452_23k256.jal
18f45218f452_fat32_sd_card.jal



sram_23k256

23K256 sram library

Author Matthew Schinkel - borntechi.com, copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4l

Description

This is library for 23K256 SPI SRAM, Microchip's 20mhz 256kbit SRAM memory


Sources

http://ww1.microchip.com/downloads/en/DeviceDoc/22100D.pdf


Notes

Address from 0 to 32,767
This is a 2.7v to 3.6v memory.
This lib should also work with 23k640 (64kbit sram), but hasn't been tested, please let me know.
Also should work with 23A640 & 23A256 (1.5v to 1.95v versions), also not tested
SPI Mode is 00 for 23k256


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f87716f877_23k256.jal
18f45218f452_fat32_sd_card.jal
18f45218f452_23k256.jal
18f45218f452_fat32_pata_hard_disk.jal



temperature_tc77

temp_TC77

Author Eur van Andel, eur@fiwihex.nl Copyright (c) 2008
Adapted-by
Compiler =2.4h

Description

this library reads the TC77 temperature sensor from Microchip.
The TC77 has a 12-bit plus sign temperature resolution of 0.0625°C 
per Least Significant Bit (LSb). It works via the SPI protocol
Specs:
1C (max.) accuracy from +25°C to +65C, 
2C (max.) accuracy from -40°C to +85C 
3C (max.) accuracy from -55°C to +125C 
2.7V to 5.5V Operating Range, Low Power: 250uA (typ.) Continuous Conversion
Mode, 0.1uA (typ.) Shutdown Mode 


--------   
I have several years of experience with hundreds of these sensors.
They work very well: fast, good accuracy, good repeatability. 
If they have an offset, it can easily be calibrated in software. 
The hard part of using this sensor is gettting it watertigtht. 
It is SMD, so it needs a PCB, and a cable. Dipping in resin or shrinking in
glue-covered shrinktube works. 
The SPI protocol is bit-banged here and can be used with any pins.
Clock data in on rising edge of clock, program must pull CS low. This allows
for multiple TC77s on the same 2-wire databus. Put a 100nF decoupling 
capacitor close the the TC77. If you don't, you WILL get weird data. 
This library assumes two pins: global bit SCK, wired to SCK of device and
global bit SIO,wired to SIO of device. SCK should be output, SIO input.
Writing the status_word is not supported here.


Dependencies


Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f876a16f876a_tc77.jal



timer0_isr_interval

timer0 isr interval

Author Joep Suijs, Copyright (C) 2008 Joep Suijs
Adapted-by Rob Hamerling
Compiler >=2.4j

Description

Fixed interval isr with support for non-blocking delays.    


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

16f648a16f648a_timer0_interval.jal
16f72316f723_timer0_interval.jal



unittest

unittests procedures

Author Sebastien Lelong, Copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4k

Description

set of procedures used to perform unittest


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

No sample found


usart_common

USART common

Author Stef Mientki Copyright (c) 2002..2006, all rights reserved.
Adapted-by Sebastien Lelong, Joep Suijs
Compiler >=2.4g

Description

USART common functions
This file provides common functions to other libraries.



Baudrate can simply be set through a human constant,
because the baudrate depending registers are calculated by this unit.
Baudrate is calculated, starting at the high baudrate flag,
which will ensure the highest possible accuracy.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

Private
  • _calculate_and_set_baudrate()

    internal function, calculates and sets baudrate divider
    and stores it in the appropiate register.
    the high-speed / low-speed bit is not stored but returned as the result
    
    Special attention is payed to the highest and lowest baudrates,
    a deviation of 5% is accepted in these cases
    
    Asynchronous baudrate settings (see also page 74/75 of DS40300B):
    {{{
    if TXSTA_BRGH = 0 (low speed)
     SPBRG = ( Fosc / ( 64 * Baudrate ) ) -1
    
    if TXSTA_BRGH = 1 (high speed)
     SPBRG = ( Fosc / ( 16 * Baudrate ) ) -1
    }}}
    
    Synchronous baudrate settings:
     * TXSTA_BRGH = 0 (low speed)
     * SPBRG = ( Fosc / ( 4 * Baudrate ) ) -1
    
    


Functions


Related samples

No sample found


usb_defs

USB constant definitions

Author Albert Faber, Copyright (c) 2008..2009, all rights reserved.
Adapted-by -
Compiler >=2.4j

Description

Constants for configurting the USB interface




Sources

http://www.usb.org for USB specifications


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions


Related samples

Here are the list of samples which use this library:

18f14k5018f14k50_usb_hid_mouse.jal
18f14k5018f14k50_usb_hid_generic.jal
18f14k5018f14k50_usb_bootloader_autostart.jal
18f14k5018f14k50_usb_bootloader.jal
18f14k5018f14k50_usb_hid_keyboard.jal
18f245018f2450_usb_hid_keyboard.jal
18f245018f2450_usb_bootloader.jal
18f245018f2450_usb_bootloader_autostart.jal
18f245018f2450_usb_hid_generic.jal
18f245018f2450_usb_hid_mouse.jal
18f455018f4550_usb_bootloader_autostart.jal
18f455018f4550_usb_hid_keyboard.jal
18f455018f4550_usb_bootloader.jal
18f455018f4550_usb_hid_mouse.jal
18f455018f4550_usb_hid_generic.jal



usb_drv

USB driver library

Author Albert Faber, Copyright (c) 2008..2009, all rights reserved.
Adapted-by -
Compiler >=2.4j

Description

This file contains the lowl level USB driver routines. It constrols
the USB serial interface engine, by managing the input and output transfers,
and calling the defined callback function when required


Sources

http://www.usb.org ; for USB specifications
         http://www.lvr.com/usbc.htm ; a lot of information about USB
         http://www.beyondlogic.org/ ; also a nice with with useful information


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

  • usb_enable_module()

    Procedure to turn on the USB device
    
    

  • usb_handle_stall()

    Procedure can be called when the USB device has to be stalled
    
    

  • usb_setup()

    Procedure to intialize the USB device, it will only do the setup, to enable
    the USB device, use the usb_enable() procedure
    
    

  • usb_handle_isr()

    This is the heard of the USB library, all pending IO transfers are handled by
    this main (interrupt) service routine. For the PIC USB device it does not make much 
    sense to use real interrupts since all real time aspects are handle by the SIE. 
    Therefore this usb_handle_isr() must be polled on a regular base, in order to 
    to keep the input and output transfers flowing
    
    

Private
  • _usb_handle_standard_request()

    Internal procedure to handle standard USB requests
    it will take care of the overall state of the device
    performing USB buffer management
    controlling the SIE
    and call the callback function if required
    
    

  • _usb_ints_on()

    Internal procedure to set the correct interrupt flags, note that for PIC USB device
    it does not make much sense to use real interrupts since all real time aspects
    are handle by the SIE. However, the library does use the interrupt flags, this
    procedure will setup to proper interrupt flags
    
    

  • _usb_handle_transaction()

    Internal procedure to handle the USB transactions
    it will take care of the overall state of the device
    performing USB buffer management
    controlling the SIE
    and call the callback function if required
    
    

  • _usb_handle_reset()

    Internal procedure to reset the USB device
    
    


Functions

  • usb_is_configured() return bit

    Function returns true if the usb device has been completely configured, otherwise
    return value will be false
    
    

  • usb_get_state() return byte

    Get the state of the USB device
    
    USB_STATE_POWERED -> USB device is powered up, ready to start negotiating
    USB_STATE_DEFAULT -> USB device is now negotiating
    USB_STATE_ADDRESS -> USB device now has an address
    USB_STATE_CONFIGURED -> USB device is completely configured and ready to rock and roll 
    
    


Related samples

Here are the list of samples which use this library:

18f14k5018f14k50_usb_hid_mouse.jal
18f14k5018f14k50_usb_hid_generic.jal
18f14k5018f14k50_usb_bootloader_autostart.jal
18f14k5018f14k50_usb_bootloader.jal
18f14k5018f14k50_usb_hid_keyboard.jal
18f245018f2450_usb_hid_keyboard.jal
18f245018f2450_usb_bootloader.jal
18f245018f2450_usb_bootloader_autostart.jal
18f245018f2450_usb_hid_generic.jal
18f245018f2450_usb_hid_mouse.jal
18f455018f4550_usb_bootloader_autostart.jal
18f455018f4550_usb_hid_keyboard.jal
18f455018f4550_usb_bootloader.jal
18f455018f4550_usb_hid_mouse.jal
18f455018f4550_usb_hid_generic.jal



usb_drv_cdc_class

USB Communication Device Class driver

Author Albert Faber, Copyright (c) 2008..2009, all rights reserved.
Adapted-by -
Compiler >=2.4j

Description

USB Communication Device Class (CDC) code
This USB library files contains the low level implementation to perform serial
communication over a USB interface. The usage of this library requires detailed
knowledge of the USB interface and requires that several configuration parameters
are defined correctly. In order to make USB serial communication more accessible 
for the end user, I would highly recommend to use the usb_serial library




Sources

http://www.usb.org for USB specifications


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Functions


API details

Global variables/contants

Procedures

Functions

  • usb_cdc_rx_avail() return bit

    This function returns there has been a character received, function will return true 
    if there is at least one pending receive character, false otherwise
    
    

  • does_sie_owns_tx_buffer() return bit

    This function returns the status of the SIE tx buffer. Either the SIE can own the
    transmit buffer (tranmit is pending) or it can be owned by the CPU. This function 
    return true if the SIE owns the buffer, otherwise false is returned
    
    

  • usb_cdc_line_status() return byte

    This function returns the line status. If on the host side the COM port has not been
    opened, the return status will be 0x00, otherwise it will be != 0
    
    

  • usb_cdc_getc() return byte

    This usb_cdc_getc function wait (blocking) until a character has been received.
    The byte value of the received character is returned by this function
    
    

  • usb_cdc_tx_empty() return byte

    This function returns the empty status of the transmit FIFO, it will return true if
    transmit FIFO is empty, false otherwise
    
    


Related samples

No sample found


usb_drv_core

USB driver library

Author Albert Faber, Copyright (c) 2008..2009, all rights reserved.
Adapted-by -
Compiler >=2.4j

Description

Routines for controlling the USB serial interface engine sending
which will ensure the highest possible accuracy.




Sources

http://www.usb.org for USB specifications


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

Private

Functions


Related samples

Here are the list of samples which use this library:

18f14k5018f14k50_usb_hid_mouse.jal
18f14k5018f14k50_usb_hid_generic.jal
18f14k5018f14k50_usb_bootloader_autostart.jal
18f14k5018f14k50_usb_bootloader.jal
18f14k5018f14k50_usb_hid_keyboard.jal
18f245018f2450_usb_hid_keyboard.jal
18f245018f2450_usb_bootloader.jal
18f245018f2450_usb_bootloader_autostart.jal
18f245018f2450_usb_hid_generic.jal
18f245018f2450_usb_hid_mouse.jal
18f455018f4550_usb_bootloader_autostart.jal
18f455018f4550_usb_hid_keyboard.jal
18f455018f4550_usb_bootloader.jal
18f455018f4550_usb_hid_mouse.jal
18f455018f4550_usb_hid_generic.jal



usb_serial

USB Serial

Author Albert Faber, Copyright (c) 2009, all rights reserved.
Adapted-by
Compiler >=2.4k

Description

The library will ease the use of for serial communication over 
the USB interface. By default nothing has to be defined by the user, below
an example how to use the library


                                                                        
include usb_serial
..
usb_serial_init()
..
;-- optionally wait till USB becomes available
while ( usb_cdc_line_status() ==  0x00 )  loop
end loop
..
;-- main loop
var byte ch
forever loop
;   -- call the flush routine on a regular base in the main loop
;   -- in order to keep the USB communicaiton alive
    usb_serial_flush()
    if ( usb_serial_read( ch ) )
		usb_serial_data = ch -- echo
	end if
    	.....
end loop


                                                                        
In addition this library can be used in combination with other JAL
libraries, like print.jal and format.jal, for example to send a
string, one can use the following code fragment:


                                                                        
const byte str[] = "Hello World"
print_string( usb_serial_data, str )


                                                                        
customization
The usb_serial library offers the following custimization prameters, 
the user has the ability to set these const parameter(s) before the 
inclusion of the usb_serial file


                                                                        
const byte USB_CDC_RX_BUFFER_SIZE = 0x??  -- set receive FIFO size
const byte USB_CDC_TX_BUFFER_SIZE = 0x??  -- set transmit FIFO size
const word USB_SERIAL_PRODUCT_ID = 0x???? -- set USB device product ID
const word USB_SERIAL_VENDOR_ID = 0x????  -- set USB device vendor ID
const byte USB_STRING0[] = { .. }         -- set USB language string
const byte USB_STRING1[] = { .. }         -- set USB mfg string
const byte USB_STRING2[] = { .. }         -- set USB product string


Notes

-


Dependencies


Summary

Global variables/contants

Procedures

Functions

Private

API details

Global variables/contants

Procedures

  • usb_serial_data'put(byte in data)

    usb_serial_data'put - write char to the USB port, blocking
    
    Asynchronuous serial send routine, using the USB Cummunication class
    Sends byte X (8 bit) to the USB host (via virtual COM port)
    Note that characters are dropped when the communcation channel on the
    USB host side is not opened (yet), this is a design choice in order to
    avoid lockup(s)
    
    

  • usb_serial_init()

    usb_serial_init will setup the USB communication, however, this can be
    a time consuming process, therefore this call is non blocking.
    In order to check if the USB device has established contact with the 
    HOST USB device, one can call the usb_is_configured() function, see
    usb_is_configured() documentation for additional details.
    
    

  • usb_serial_flush()

    usb_serial_flush shall be called on a regular base (millisecond range)
    in order to keep the USB transmision alive. Therfore it is adviced to
    call the usb_serial_flush procedure in the main loop of your 
    application
    
    

  • usb_serial_write(byte in data)

    usb_serial_write - write char to the USB port, blocking
    
    Asynchronuous serial send routine, using the USB Cummunication class
    Sends byte X (8 bit) to the USB host (via virtual COM port)
    Checks (and waits if necessary) if FIFO buffer is full
    Note that characters are dropped when the communcation channel on the
    USB host side is not opened (yet), this is a design choice in order to
    avoid lockup(s)
    
    

Functions

  • usb_serial_data'get() return byte

    usb_serial_data'get() - read a char (blocking!)
       
    usb_serial_data'get() waits till a character has been received and
    returns it
    
    

  • usb_serial_read(byte out data) return bit

    usb_serial_read - read char if available (non-blocking)
       
    usb_serial_read returns true if a character has been received, 
    otherwise returns false. If function returns true, the data variable
    is valid, and contains the character that has been received. In other
    cases the data variable is not defined
    Note that characters are dropped when the communcation channel on the
    USB host side is not opened (yet), this is a design choice in order to
    avoid lockup(s)
    
    

Private
  • _usb_serial_read(byte out data) return bit

    _usb_serial_read - internal use only!
    
    _usb_serial_read returns true if a character has been received, 
    otherwise returns false. If function returns true, the data variable
    is valid, and contains the character that has been received. In other
    cases the data variable is not defined
    Note that characters are dropped when the communcation channel on the
    USB host side is not opened (yet), this is a design choice in order to
    avoid lockup(s)
    
    



Related samples

Here are the list of samples which use this library:

18f14k5018f14k50_usb_serial.jal
18f245018f2450_usb_serial.jal
18f455018f4550_usb_serial.jal