Configure DAC channels on ADAC click

General discussion on mikroC PRO for ARM.
Post Reply
Author
Message
mjgunn
Posts: 1
Joined: 03 Dec 2020 02:19

Configure DAC channels on ADAC click

#1 Post by mjgunn » 08 Feb 2023 21:25

Hello,

I've worked through the ADAC Click example from library stock manager, and it compiles on mikroC Pro for ARM and runs on a Clicker 2 board. But I'm having problems extending the program and configuring further IO channels for DAC (yes, I'm new at this). The configuration part of the code contains the lines:
void configurationTask()
{
adac_setConfiguration( _ADAC_DAC_CONFIG, _ADAC_NO_OP, _ADAC_IO1 ); // IO1 is configured as an output port
Delay_ms( 100 );
adac_setConfiguration( _ADAC_ADC_CONFIG, _ADAC_NO_OP, _ADAC_IO4 ); // IO4 is configured as an input port
Delay_ms( 100 );
adac_setConfiguration( _ADAC_ADC_SEQUENCE, _ADAC_SEQUENCE_ON, _ADAC_IO4 );
Delay_ms( 100 );
}

Which gives IO1 as a DAC and IO4 as an ADC.

If I try to add, say, IO7 as a further DAC as follows:
{
adac_setConfiguration( _ADAC_DAC_CONFIG, _ADAC_NO_OP, _ADAC_IO1 ); // IO1 is configured as an output port
Delay_ms( 100 );
adac_setConfiguration( _ADAC_DAC_CONFIG, _ADAC_NO_OP, _ADAC_IO7 ); // IO7 is configured as an output port
Delay_ms( 100 );
adac_setConfiguration( _ADAC_ADC_CONFIG, _ADAC_NO_OP, _ADAC_IO4 ); // IO4 is configured as an input port
Delay_ms( 100 );
adac_setConfiguration( _ADAC_ADC_SEQUENCE, _ADAC_SEQUENCE_ON, _ADAC_IO4 );
Delay_ms( 100 );
}

It seems to forget about IO1 as a DAC channel.

The second last line of the code:

adac_setConfiguration( _ADAC_ADC_SEQUENCE, _ADAC_SEQUENCE_ON, _ADAC_IO4 );

seems to add IO4 to the sequence.

Is there an equivalent to add the DAC channel. I've tried: adac_setConfiguration( _ADAC_DAC_SEQUENCE, _ADAC_SEQUENCE_ON, _ADAC_IO7 ); and other permeations .. to no effect.

Thanks in advance.

Smart_Aleck
Posts: 16
Joined: 07 Feb 2023 20:45

Re: Configure DAC channels on ADAC click

#2 Post by Smart_Aleck » 20 Feb 2023 10:30

Hi,

at the first glance I think you need to OR the channels you like to have as DAC, like

Code: Select all

adac_setConfiguration( _ADAC_DAC_CONFIG, _ADAC_NO_OP, _ADAC_IO1 | _ADAC_IO7 );
Please let me know if this works

Post Reply

Return to “mikroC PRO for ARM General”