2015-02-15

8bit LED control


hi, here is second, let's see how it works LED on avr module on last video and some sample code.


case light_on:  DDRA = 0xff; PORTA = 0xff;  ptr->light_state = ON; break;
case light_off: DDRA = 0;    PORTA = 0;     ptr->light_state = OFF;break;

as you know in my code this is " switch ~ case " this is "C" language.
normally you should know 'C' first :) and DDRA means Data Direction Register Address
DDRA is 8bit register 0000 0000 -> high 4bit low 4bit.

DDRA = 0xff  -> put the data in register like this " 1111 1111 " .

PORTA is General I/O port pin register you may check Ateml-128 Avr 8bit datasheet, it's great for understand the every terms.

ptr->light_state = ON; is struct in "C"  so light_on is make the ddra register as 1111 1111.   DDRA = 0xff and PORTA = 0xff  it result each 8 pins is signally 1 (2.7~3V).








No comments:

Post a Comment

Total Pageviews