TOP Contributors

  1. MIKROE (2654 codes)
  2. Alcides Ramos (352 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136743 times)
  2. FAT32 Library (69952 times)
  3. Network Ethernet Library (55942 times)
  4. USB Device Library (46267 times)
  5. Network WiFi Library (41887 times)
  6. FT800 Library (41173 times)
  7. GSM click (28985 times)
  8. PID Library (26413 times)
  9. mikroSDK (26362 times)
  10. microSD click (25376 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
Library

PIC24F ADC library with callback

Rating:

0

Author: Anton Rieckert

Last Updated: 2016-02-22

Package Version: 1.0.0.0

Category: Internal MCU modules

Downloaded: 1278 times

Followed by: 2 users

License: MIT license  

Analog to Digital Library for the PIC24 and dsPIC range. Library supports multiple channels and has a callback function that is executed as soon as all the channels are read. The sampling frequency can also be specified in Hz

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "PIC24F ADC library with callback" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "PIC24F ADC library with callback" changes.

Do you want to report abuse regarding "PIC24F ADC library with callback".

  • Information
  • Comments (0)

Library Blog

Example

program ADCExample;
uses libADC;

//==============================================================================
procedure InitCPU;
begin
  // Disable all ADC
  AD1PCFG := 0xFFFF;

  TRISA := 0x0004;
  TRISB := 0x0015;
end;

//==============================================================================
procedure SamplesReadyCallback(ANumOfSamples : word; var ASamples : array[16] of word);
var
  i   : word;
  txt : string[20];
begin
  // This function is called every Afs milliseconds
  // The ANumberOfSamples would be the same as the number of Achannels you 
  // specified in the init function
  
  // ASamples is an array containing the sampled values
  for i := 0 to ANumOfSamples - 1 do
  begin
    // Do something with your sampled values
    UART1_Write_Text('Channel ' + char(i + 1 + 48) + ': ');
    WordToStr(ASamples[i], txt);
    UART1_Write_Text(txt + #13 + #10);
  end;
end;

//==============================================================================
begin
  InitCPU;

  // Init the UART comms port
  UART1_Init(19200);
  UART1_Write_Text('Hello, this is the ADC test program' + #13 + #10);

  // Init the ADC (3 parameters - channel mask, sample time, callback)
  // Achannles - Channel mask of the channels you want to read
  // Afs - sample frequency (Hz)
  // aCallback - callback function when samples are ready
  ADC_Init(0x0003, 800, @SamplesReadyCallback);
  
  // In this example we read AN0 and AN1 (0x0003)
  // Every 800Hz or 1.25ms
  // And call SamplesReadyCallback function with the values
  
  // To read for example AN0, AN1 and AN6 the Achannels would be 0x0043

  ADC_Enable;
  ADC_StartSample;

  // Endless loop or your main program
  // The ADC library will call the callback function
  while true do;
end.

ALSO FROM THIS AUTHOR

OneWire Communication Library with Search functionality

0

This is a library written for the mikroPascal compilers to interface to these devices on a single bus. The library also includes functions that allows the master device to discover the number of slave devices on the bus and read there serial numbers.

[Learn More]

PIC24F Timer modules with callback support

0

This library makes it easier to work with the build in timer modules of the PIC24F range. There are 2 units you can include in your source code. The initialisation function takes 2 parameters, the interval in milliseconds and the callback function that should be executed.

[Learn More]

DateTime utilities compatible with Delphi and Lazarus

0

This unit provides you with the functionality to work with date time variables the same way that Delphi and Lazarus handles them. The unit supports - Leap year, - Encode date-time, - Decode date-time, - Increment and decrement functions, - Period functions such as minutes between two dates

[Learn More]