ахам мерси
Опитвам се по този асемблерски код да напиша програма на C aма нещо не се получава същият ефект
#include <p16F690.inc>
__config (_INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_OFF & _MCLRE_OFF & _CP_OFF & _BOR_OFF & _IESO_OFF & _FCMEN_OFF)
cblock 0x20
Delay1 ; Assign an address to label Delay1
Delay2
Display ; define a variable to hold the diplay
endc
org 0
Start:
bsf STATUS,RP0 ; select Register Page 1
movlw 0xFF
movwf TRISA ; Make PortA all input
clrf TRISC ; Make PortC all output
movlw 0x10 ; A2D Clock Fosc/8
movwf ADCON1
bcf STATUS,RP0 ; back to Register Page 0
bcf STATUS,RP0 ; address Register Page 2
bsf STATUS,RP1
movlw 0xFF ; we want all Port A pins Analoga
movwf ANSEL
bcf STATUS,RP0 ; address Register Page 0
bcf STATUS,RP1
movlw 0x01
movwf ADCON0 ; configure A2D for Channel 0 (RA0), Left justified, and turn on the A2D module
MainLoop:
nop ; wait 5uS for A2D amp to settle and capacitor to charge.
nop ; wait 1uS
nop ; wait 1uS
nop ; wait 1uS
nop ; wait 1uS
bsf ADCON0,GO ; start conversion
btfss ADCON0,GO ; this bit will change to zero when the conversion is complete
goto $-1
swapf ADRESH,w ; Copy the display to the LEDs
movwf PORTC
goto MainLoop
end
нещо несъм направил както трябва ама немога да разбера кое ако може малко подсказка
това е на C
#include <16f690.h>
#DEVICE *=16 ADC=10
#include <stdio.h>
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOCPD //Data EEPROM Code Protected
#FUSES NOPROTECT //Code protected from reads
#FUSES NOMCLR //Master Clear pin enabled
#FUSES PUT //Power Up Timer
#FUSES NOBROWNOUT //Reset when brownout detected
#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_A5,rcv=PIN_A4,bits=8)
void main()
{
long value;
set_tris_A(0xff);
set_tris_C(0x00);
setup_adc(ADC_CLOCK_DIV_8);
SETUP_ADC_PORTS(ALL_ANALOG);
set_adc_channel(0);
while(true)
{
delay_us(5);
value=read_adc();
output_C(value);
}
read_adc(ADC_start_only);
sleep();
value=read_adc(ADC_READ_ONLY);
}