【发布时间】:2015-01-19 00:19:40
【问题描述】:
我正在使用avr-ada 来编译我的程序。我想将unsigned_16 变量右移两次。
Interfaces.Shift_Right 被重载,同时提供Unsigned_8 和Unisgned_16。
当我编译时,我得到错误'expected type "Interfaces.Unsigned_8"','found type "Interfaces.Unsigned_16"'。我试图指定输入是Unsigned_16,但它不起作用。如何指定正确的函数?
with AVR; use AVR;
with AVR.MCU;
with AVR.Timer0;
with AVR.ADC;
with Interfaces;
use Interfaces;
procedure Flash_Led is
adc_result_10 : Unsigned_16 := 0;
adc_result_8 : Unsigned_8 := 0;
begin
-- set OC0A pin as output, required for output toggling
MCU.DDRD_Bits := (others => DD_Output);
-- set all pins low
MCU.PortD := 16#00#;
-- clear register
MCU.TCCR0B := 16#00#;
-- initialize timer to Clear Timer on Compare, scale the input
-- clock and set a value to compare the timer against.
Timer0.Init_CTC (Timer0.Scale_By_1024, Overflow => 1);
-- Toggle the OC0(A)-Pin on compare match
Timer0.Set_Output_Compare_Mode_Toggle;
-- Initialize ADC
ADC.Init(ADC.Scale_By_64, Ref => ADC.Is_Vcc);
loop -- loop forever
adc_result_10 := ADC.Convert_10bit(Ch => 0);
adc_result_10 := Shift_Right(Unsigned_16'(adc_result_10), 2); --'
adc_result_8 := Unsigned_8(adc_result_10);
Timer0.Set_Overflow_At(adc_result_10);
end loop;
end Flash_Led;
【问题讨论】:
-
你打电话给
Right_Shift还是Shift_Right?请更新您的问题以显示说明问题的(小)完整程序。 -
This 在 Linux 上使用 GNAT 编译没有错误(指的是 pastebin 上的示例,而不是问题中的代码)。