Sound_Play

General discussion on mikroPascal PRO for ARM.
Post Reply
Author
Message
Vit2
Posts: 77
Joined: 15 Apr 2015 10:00

Sound_Play

#1 Post by Vit2 » 24 Oct 2020 08:14

Hello!
How can I do, for example, send 3.3v to PB13 and from PB12 receive the Sound_Play (1000, 100) signal ;?
thanks

Vit2
Posts: 77
Joined: 15 Apr 2015 10:00

Re: Sound_Play

#2 Post by Vit2 » 26 Oct 2020 07:39

Hello!
Why can't I call the procedure VoltMeter? LED works! STM32F103

case X of
3:LED := 0; // 0 On
4:LED := 1; // 1 Off
5: VoltMeter;
end;

Thanks.

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

Re: Sound_Play

#3 Post by filip » 26 Oct 2020 14:11

Hi,

Can you please attach minimal project that demonstrates this issue ?

Regards,
Filip.

Vit2
Posts: 77
Joined: 15 Apr 2015 10:00

Re: Sound_Play

#4 Post by Vit2 » 26 Oct 2020 14:39

procedure VoltMeter;
begin
if (UART1_Data_Ready() <> 0) then // If data is received
begin
ADC_V := ADC1_Get_Sample (0); // read analog value from ADC1 module channel 0
//-------------------------- Volt --------------------------------------------------------------
Delay_ms(50);
Ref := 3.307 / 4095;
Delay_Cyc(102000); // 1 cycles pause
UART1_Read_Text(TestDelitel, '', 1);
XDelitel:= StrToInt(TestDelitel);
case XDelitel of
1:V := (ADC_V * Ref) * 10.05;
2:V := (ADC_V * Ref) * 9.9;// 1:10
end;
FloatToStr(V, Vtxt);
Vtxt[5]:= 0;
UART1_Write_Text(Vtxt);
end;

end;

////------------------------------------------------------------------------------------------------
begin
PortCofig();
/// 8.000000
UART1_Init_Advanced (115200, _UART_8_BIT_DATA, _UART_NOPARITY, _UART_ONE_STOPBIT, @_GPIO_MODULE_USART1_PA9_10);
Delay_ms(100); // Wait for UART module to stabilize
while (TRUE) do
begin
if (UART1_Data_Ready() <> 0) then // If data is received
begin
UART1_Read_Text(Test, '', 1);
X:= StrToInt(Test);
case X of
3:LED := 0; // 0 On
4:LED := 1; // 1 Off
5: VoltMeter;
end;
end;
end;
end.

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

Re: Sound_Play

#5 Post by filip » 27 Oct 2020 15:17

Hi,

Although your code cannot be compiled, the VoltMeter procedure will be executed if the case state is 5, I have checked this in simulator.

Regards,
Filip.

Vit2
Posts: 77
Joined: 15 Apr 2015 10:00

Re: Sound_Play

#6 Post by Vit2 » 27 Oct 2020 16:21

Hello!
Why won't it compile?
Procedure Voltmeter compiles and works. But I cannot call her.

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

Re: Sound_Play

#7 Post by filip » 28 Oct 2020 11:11

Hi,

It won't compile as it lacks some declarations, like ADC_V, Ref, XDelitel, Vtxt variables and PortCofig procedure is missing definition.

Regards,
Filip.

Vit2
Posts: 77
Joined: 15 Apr 2015 10:00

Re: Sound_Play

#8 Post by Vit2 » 28 Oct 2020 19:57

Hi, sorry


var uart_rd : byte;
X,XDelitel:Integer;
V,Ref:real;
ADC_V:word;
Vtxt : array[23] of char;
TestDelitel, Test: array[6] of char;
LED: sbit at GPIOC_ODR.B13;
///----------------------------------------------------------------------------------------
procedure PortCofig();
begin
GPIO_Digital_Output(@GPIOC_BASE, _GPIO_PINMASK_13);
LED := 1;
GPIO_Digital_Input(@GPIOA_ODR, _GPIO_PINMASK_0); // A0 Âîëüò
ADC_Set_Input_Channel(_ADC_CHANNEL_0);
ADC1_Init();
end;

AntiMember
Posts: 136
Joined: 02 Jan 2020 19:00

Re: Sound_Play

#9 Post by AntiMember » 29 Oct 2020 09:31

-

Post Reply

Return to “mikroPascal PRO for ARM General”