mikroC PRO for ARM, STM32F3 DISCOVERY, no ADC4 in ADC.h file

General discussion on mikroC PRO for ARM.
Post Reply
Author
Message
ratchapolp
Posts: 7
Joined: 18 Aug 2016 15:34

mikroC PRO for ARM, STM32F3 DISCOVERY, no ADC4 in ADC.h file

#1 Post by ratchapolp » 18 Aug 2016 17:21

Hi,

I use mikroC PRO for ARM, STM32F3 DISCOVERY.
I can use ADC1, 2, 3 but can't use ADC4.
The ADC.h file does not include the ADC4.
Could you help me for this?

Thank you very much.

User avatar
lana.arsic
mikroElektronika team
Posts: 1715
Joined: 15 Jan 2016 12:50

Re: mikroC PRO for ARM, STM32F3 DISCOVERY, no ADC4 in ADC.h

#2 Post by lana.arsic » 19 Aug 2016 14:23

Hi ratchapolp,

Welcome to the MikroE forum.

Can you please explain on which file you are referring to?

ADC4 for STM32F303VC is supported in our compiler,
you can try to use it with ADC Library (which you can select in Library Manager).

Best regards,
Lana

ratchapolp
Posts: 7
Joined: 18 Aug 2016 15:34

Re: mikroC PRO for ARM, STM32F3 DISCOVERY, no ADC4 in ADC.h

#3 Post by ratchapolp » 19 Aug 2016 14:36

The code is below, it can reading the voltage when use ADC1, ADC2 and ADC3. When I used ADC4 (ADC4_init();), the program hang up, no respond.

unsigned int adc_avg(unsigned char no_of_samples, unsigned char ADCx, unsigned char Channelx)
{
unsigned long avg = 0;
unsigned char samples = no_of_samples;

if (ADCx == 1)
{
ADC1_init(); // It is OK.
while(samples > 0)
{
avg += ADC1_Get_Sample(Channelx);
samples--;
}
}
else if (ADCx == 2)
{
ADC2_init(); // It is OK.
while(samples > 0)
{
avg += ADC2_Get_Sample(Channelx);
samples--;
}
}
else if (ADCx == 3)
{
ADC3_init(); // It is OK.
while(samples > 0)
{
avg += ADC3_Get_Sample(Channelx);
samples--;
}
}
else if (ADCx == 4)
{
ADC4_init(); //When I used ADC4, the program hang up, no respond.
while(samples > 0)
{
avg += ADC4_Get_Sample(Channelx);
samples--;
}
}
avg /= no_of_samples;
return avg;
}

ratchapolp
Posts: 7
Joined: 18 Aug 2016 15:34

Re: mikroC PRO for ARM, STM32F3 DISCOVERY, no ADC4 in ADC.h

#4 Post by ratchapolp » 20 Aug 2016 19:42

Hi

I forgot attached a ADC.h file.
I downloaded from http://libstock.mikroe.com/projects/vie ... c-examples.

Thank you

ratchapolp
Posts: 7
Joined: 18 Aug 2016 15:34

Re: mikroC PRO for ARM, STM32F3 DISCOVERY, no ADC4 in ADC.h

#5 Post by ratchapolp » 21 Aug 2016 06:11

Hi

I found the problem in .lst file at
___GenExcept:
;__Lib_System_3XX.c, 310 ::
0x2CA0 0xB081 SUB SP, SP, #4
;__Lib_System_3XX.c, 311 ::
L___GenExcept27:
0x2CA2 0xE7FE B L___GenExcept27

It will loop at 0x2CA2
Could you suggest for me?

User avatar
lana.arsic
mikroElektronika team
Posts: 1715
Joined: 15 Jan 2016 12:50

Re: mikroC PRO for ARM, STM32F3 DISCOVERY, no ADC4 in ADC.h

#6 Post by lana.arsic » 22 Aug 2016 11:38

Hi,

I have tested ADC4 on EasyMx PRO v7 for STM32 board
with STM32F303VC and it works properly.

As regards problem with debugger, you can try to change your code,
and as regards ADC.h file, please contact author of that example.

Best regards,
Lana

ratchapolp
Posts: 7
Joined: 18 Aug 2016 15:34

Re: mikroC PRO for ARM, STM32F3 DISCOVERY, no ADC4 in ADC.h

#7 Post by ratchapolp » 22 Aug 2016 11:52

Hi Lana,

Could you share your code for me?

Thank you very much.

User avatar
lana.arsic
mikroElektronika team
Posts: 1715
Joined: 15 Jan 2016 12:50

Re: mikroC PRO for ARM, STM32F3 DISCOVERY, no ADC4 in ADC.h

#8 Post by lana.arsic » 23 Aug 2016 12:03

Hi ratchapolp,

I'm sorry, I have already used corrected library.

I'm sending you in attachment that library which you need to replace with
__Lib_ADC_1234_30X.emcl in Uses folder which is located in e.g.
C:\Users\Public\Documents\Mikroelektronika\mikroC PRO for ARM\Uses\ST M4.

Also, I'm sending you in attachment example for ADC4.

Best regards,
Lana
Attachments
ADC Demo.zip
(11.51 KiB) Downloaded 132 times
__Lib_ADC_1234_30X.zip
(5.86 KiB) Downloaded 129 times

ratchapolp
Posts: 7
Joined: 18 Aug 2016 15:34

Re: mikroC PRO for ARM, STM32F3 DISCOVERY, no ADC4 in ADC.h

#9 Post by ratchapolp » 23 Aug 2016 12:27

Hi Lana,

Thank you very much for your help.
It works.
I can read ADC1, ADC2, ADC3 and ADC4.

Thank you.

User avatar
lana.arsic
mikroElektronika team
Posts: 1715
Joined: 15 Jan 2016 12:50

Re: mikroC PRO for ARM, STM32F3 DISCOVERY, no ADC4 in ADC.h

#10 Post by lana.arsic » 23 Aug 2016 13:28

Hi ratchapolp,

You're welcome, I'm glad it was helpful.

Best regards,
Lana

Bouguezzi
Posts: 2
Joined: 18 Feb 2016 17:16

Re: mikroC PRO for ARM, STM32F3 DISCOVERY, no ADC4 in ADC.h file

#11 Post by Bouguezzi » 17 Feb 2022 00:11

Hi, I'm new in programming microcontrollers. I used Mikroc Pro For ARM to make my code of ADC with STM32L152RBT6.
The program started correctly but when it reaches the line of reading the value from the adc channel it complains. Please help me. Is there a necessary configuration !!
thanks in advance

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: mikroC PRO for ARM, STM32F3 DISCOVERY, no ADC4 in ADC.h file

#12 Post by filip » 28 Feb 2022 12:20

Hi,

Can you please explain your issue in details ?

Regards,
Filip.

Post Reply

Return to “mikroC PRO for ARM General”