Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Hi , i tryed this code but it is not working as a pwm for led
where is the problem?
is it here ? How can we use newlevel1 as a pwm value?
"" pwm portc.2, newlevel1 ,100 'i want dimming a LED on PORTC.2"""
************************************************** *******
************************************************** *******
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
ADCON0=0
ADCON1=7
adresse_grada = 2
checkdmx:
counter = 1
pulsin portc.7,0,counter
if counter = 0 then
idleflag = 1
endif
if counter < 40 then checkdmx
dummy = RCREG
dummy = RCREG
SPBRG = 0
TXSTA.2 = 0 'brgh = 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
for x = 1 to aminus
while RCIF = 0:WEND
dummy = RCREG
next x
newlevel1 = RCREG
pwm portc.2, newlevel1 ,100 ' HERE PROBLEM I THINK
RCSTA.7 = 0
goto checkdmx
return
Hi and welcome on the forum.
1. Those DEFINE's HSER_xxxx are not needed if you're not using HSERIN.
2. it look like another DMX routine to me
What's working and what doesn't?
Do you understand the DMX protocol?
How about your schematic, configuration fuses, PIC#?
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks