2014-12-30 6 views
0

내 프로그램을 컴파일하는 데 avr-ada을 사용하고 있습니다. unsigned_16 변수를 두 번 오른쪽으로 이동하고 싶습니다. Interfaces.Shift_Right은 오버로드되어 Unsigned_8Unisgned_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; 
+0

'Right_Shift' 또는'Shift_Right'를 호출하고 있습니까? 질문을 업데이트하여 문제를 보여주는 완전한 프로그램을 보여주십시오. –

+0

[This] (http://pastebin.com/YLWG0ae2)는 Linux에서 GNAT를 사용하여 오류없이 컴파일합니다 (질문의 코드가 아닌 pastebin의 예제 참조). –

답변

0

라인 :

Timer0.Set_Overflow_At(adc_result_10); 

가되어 있어야합니다 :

Timer0.Set_Overflow_At(adc_result_8); 

내가 밀접하게 충분한 오류 메시지의 줄 번호에 보이지 않았다. 죄송합니다.

0

당신은 항상 이름 변경을 통해 고유 한 이름을 구성 할 수 있습니다 (이 과부하 주어진)라고되고있는 기능을 모르는 경우 ...

function My16_Shift_Right (Item : in Unsigned_16; Amount : Natural) return Unsigned_16 
    renames Interfaces.Shift_Right; 

한 다음 프로그램에 대해 생각하는 방식을 테스트 .

+0

좋은 팁입니다. 감사. – userYou

관련 문제