Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
et:examples:setup:off [2010/11/09 09:41] raivo.sellet:examples:setup:off [2020/07/20 12:00] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +<code c>
 +#include <stdlib.h>
 +#include <avr/io.h>
  
 + 
 +#define SETTO(value, bit, to) value = ((to) ? value | BIT(bit) : value & ~BIT(bit)) 
 +#define ISSET(value, bit) ((value) & (BIT(bit)))
 +#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 ("nop");
 + }
 +}
 + 
 +int main(void)
 +{
 + // Initialize display, cursor off
 +
 + // Clear display and home cursor
 +
 +
 +    //Clear 7-seg
 + DDRC |= 0xCF;
 + DDRG |= 0x04;
 +
 + PORTC |= 0x38;
 +  PORTG CLR(2);
 + 
 + 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); 
 +}
 +
 +</code>
 +
 +{{:et:supervisors:solutions:andurid_4_termistor.hex|}}
 +
 +{{:et:supervisors:solutions:andurid_2_kaugus_algeline.hex|}}
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0