@Mister_e
@Skimask
thanks for help me and look to my code please what is problem on it i have pic 16F877A and i use pbp 2,47 i have found this code int he forum and little designed it back for my Pic16F877A but it is not working i want to dim a led on portc1 (portc1and portc2 is pwm port on 877A pic) i want to dimming it but some probşlem on the code can you look and say what is my problem here?
'----------------------------------------------------------------------
INCLUDE "modedefs.bas"
@ DEVICE HS_OSC
@ DEVICE pic16F877A
@ DEVICE pic16F877A, WDT_OFF
@ DEVICE pic16F877A, PWRT_ON
@ DEVICE pic16F877A, PROTECT_OFF
@ DEVICE pic16F877A, BOD_OFF
'----------------------------------------------------------------------
DEFINE OSC 20
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_SPBRG 4
DEFINE HSER_BAUD 250000
DEFINE HSER_CLROERR 1
'----------------------------------------------------------------------
counter VAR word
idleflag VAR WORD
dummy VAR WORD
RCIF VAR byte
startcode VAR WORD
aminus VAR WORD
adresse_grada VAR WORD
x VAR WORD
newlevel1 VAR WORD
'----------------------------------------------------------------------
TRISB=0
TRISC=%10000000 ' portc.7 is RX input
ADCON0=0
ADCON1=7
adresse_grada=2
checkdmx:
counter = 1
pulsin portc.7,0,counter ' portc.7 is RX input
if counter = 0 then
idleflag = 1
endif
if counter < 40 then checkdmx
dummy = RCREG
dummy = RCREG
SPBRG = 0
TXSTA.2 = 0
TXSTA.4 = 0
RCSTA.7 = 1
RCSTA.6 = 0
RCSTA.4 = 0
RCSTA.4 = 1
while RCIF = 0:wend
startcode = RCREG
if startcode <> 0 then checkdmx
aminus = adresse_grada - 1 'address1 is my target address
for x = 1 to aminus
while RCIF = 0:WEND
dummy = RCREG
next x
newlevel1 = RCREG
pwm portc.1,newlevel1 ,100 'i want dimming a LED on PORTC.1
RCSTA.7 = 0 'turn off the USART
goto checkdmx
return
Bookmarks