내 프로그램을 컴파일하는 데 avr-ada
을 사용하고 있습니다. unsigned_16
변수를 두 번 오른쪽으로 이동하고 싶습니다. Interfaces.Shift_Right
은 오버로드되어 Unsigned_8
과 Unisgned_16
을 모두 제공합니다.Ada 컴파일러가 잘못된 오버로드 된 함수를 선택했습니다.
컴파일 할 때 '예상 유형 "Interfaces.Unsigned_8"', '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] (http://pastebin.com/YLWG0ae2)는 Linux에서 GNAT를 사용하여 오류없이 컴파일합니다 (질문의 코드가 아닌 pastebin의 예제 참조). –