# dac_mcp4922

MCP4922.jal

Author | Peter Lankreijer
Adapted-by |
Compiler | 2.4o

Description

    This library controls a MCP4922 via the SPI protocol.

Sources

    delay.jal
                 spi_master_sw.jal or spi_master_hw.jal
                 http://ww1.microchip.com/downloads/en/DeviceDoc/22250A.pdf

Notes

    The following should be defined in the main program:
                 setup SPI for software SPI or none for hardware SPI
                 include spi_master_sw
                 define directions
                 spi_master_sw_init(SPI_MODE_11)
                 alias spi_master is spi_master_sw
                 alias spi_master_exchange is spi_master_sw_exchange

Dependencies

- delay

## Summary

### Global variables/contants

- `var bit mcp4922_shdn at mcp4922_write[1] : 4`
- `var bit _mcp4922_buf`
- `var bit _mcp4922_ga`
- `var bit _mcp4922_shdn`
- `var bit mcp4922_ga at mcp4922_write[1] : 5`
- `var byte mcp4922_write[2]`
- `var bit mcp4922_buf at mcp4922_write[1] : 6`
- `var bit mcp4922_ab at mcp4922_write[1] : 7`

### Procedures

- `mcp4922_dac_ab(word in A, word in B)`
- `mcp4922_dac(bit in register, word in X)`
- `mcp4922_init(bit in buffer, bit in gain)`
- `mcp4922_split_word(word in word_in, byte out high_byte, byte out low_byte)`
- `mcp4922_dac_a(word in A)`
- `mcp4922_dac_b(word in B)`

### Functions

## API details

### Global variables/contants

- `var bit mcp4922_shdn at mcp4922_write[1] : 4`

      Output shutdown control bit

- `var bit _mcp4922_buf`

  No documentation found

- `var bit _mcp4922_ga`

  No documentation found

- `var bit _mcp4922_shdn`

  No documentation found

- `var bit mcp4922_ga at mcp4922_write[1] : 5`

      Output gain selection bit

- `var byte mcp4922_write[2]`

      Define variables

- `var bit mcp4922_buf at mcp4922_write[1] : 6`

  No documentation found

- `var bit mcp4922_ab at mcp4922_write[1] : 7`

      select DAC_A OR DAC_B

### Procedures

- `mcp4922_dac_ab(word in A, word in B)`

      Function to write to the DAC and update both registers at the same time

- `mcp4922_dac(bit in register, word in X)`

      Internal procedure to wite to the register

- `mcp4922_init(bit in buffer, bit in gain)`

      Initialise the MCP4922

- `mcp4922_split_word(word in word_in, byte out high_byte, byte out low_byte)`

      Internal used function to split a word into two bytes

- `mcp4922_dac_a(word in A)`

      Function to write to the DAC A and latch

- `mcp4922_dac_b(word in B)`

      Function to write to the DAC B and latch

### Functions

## Related samples

Here are the list of samples which use this library:

18f27j53 | 18f27j53_mcp4922.jal