??? 07/11/06 10:58 Read: times |
#120010 - snippet: blinkey |
An attempt of code snippet: blinkey.
After discussion and cleanup I'll post it as a FAQ. Jan Waclawek ;Name: Blinkey ; ;What does it do: Blinks with a LED ; ;What if it does not blink: See "Basic troubleshooting FAQ" ; ;Required hardware: ;- any '51 with reset, clock (crystal), power supply connected ;- if code in internal memory (FLASH), don't forget to connect ; /EA to VCC ;- one LED, cathode to port pin (see HW dependent code), ; anode via a series resistor (300 Ohm - 1kOhm) connected to VCC ; ;Reference assembler: asm51 from metalink webpage ;for other assemblers remove the following line ; (causes a "duplicate definition" or similar error) P3 EQU 0B0h ; ; ;HW dependent code Pin EQU P3.0 ;pin, where LED is connected Timing EQU 4 ;using this value, it flashes approx. 1/sec on 12-clock '51 @ 12MHz ;on slightly faster hardware (e.g. 6-clocker at 20MHz) ; should work, but blinks faster ;on significantly faster hardware, increase this value ; appropriately, as too fast blinking might seem ; as if LED is continouosly ON ;code main ;ORG 0 and/or CSEG omitted for simplicity - most asms have these as default ; X0: cpl Pin ;toggle LED state mov r2,#Timing ;load timing value X1: djnz r0,X1 ;timing done by simple nested loops djnz r1,X1 ; - not precise, but good for blinkey djnz r2,X1 sjmp X0 end The resulting "reference" hex: :0C000000B2B07A04D8FED9FCDAFA80F421 :00000001FF |
Topic | Author | Date |
snippet: blinkey | 01/01/70 00:00 | |
points | 01/01/70 00:00 | |
I see no other way... | 01/01/70 00:00 | |
wrong assumption | 01/01/70 00:00 | |
test HW | 01/01/70 00:00 | |
what is the point then | 01/01/70 00:00 | |
I think we should rethink our attitude a bit![]() | 01/01/70 00:00 |