This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| et:examples:setup:off [2010/11/09 09:40] – tekitatud raivo.sell | et:examples:setup:off [2020/07/20 12:00] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | <code c> | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | #define SETTO(value, | ||
| + | #define ISSET(value, | ||
| + | #define BIT(x) (1 << (x)) | ||
| + | #define SET(x) |= BIT(x) | ||
| + | #define CLR(x) &= ~BIT(x) | ||
| + | |||
| + | void nop_delay(unsigned int count) | ||
| + | { | ||
| + | for (unsigned int i = 0; i < count; i++) | ||
| + | { | ||
| + | asm volatile (" | ||
| + | } | ||
| + | } | ||
| + | |||
| + | int main(void) | ||
| + | { | ||
| + | // Initialize display, cursor off | ||
| + | |||
| + | // Clear display and home cursor | ||
| + | |||
| + | |||
| + | | ||
| + | DDRC |= 0xCF; | ||
| + | DDRG |= 0x04; | ||
| + | |||
| + | PORTC |= 0x38; | ||
| + | | ||
| + | |||
| + | for (signed char i = 7; i >= 0; i--){ | ||
| + | PORTC CLR(6); | ||
| + | // Clock high for certain period | ||
| + | PORTC SET(7); | ||
| + | nop_delay(8); | ||
| + | // Clock low for certain period | ||
| + | PORTC CLR(7); | ||
| + | nop_delay(8); | ||
| + | } | ||
| + | PORTG SET(2); | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | {{: | ||
| + | |||
| + | {{: | ||