oprogramowanie przerwań od timera w sam7s

Witam.

Analizuje ponizszy przyklad kodu i nie moge dojsc w ktorym to miejscu ustawiany jest stan licznika od ktorego zaczyna liczyc timer? Czy moge prosic o pomoc?

#include <targets/AT91SAM7.h>

// Interrupt definitions #define AIC_SMR(n) (*(&AIC_SMR0 + n)) #define AIC_SVR(n) (*(&AIC_SVR0 + n))

#define AIC_SRCTYPE_INT_LEVEL_SENSITIVE 0x00 /* Level Sensitive */ #define AIC_SRCTYPE_INT_EDGE_TRIGGERED 0x20 /* Edge Triggered */

#define TC0_ID 12

// Timer definitions #define TC_CLKEN 0x1 #define TC_CLKDIS 0x2 #define TC_SWTRG 0x4

#define TC_CLKS 0x7 #define TC_CLKS_MCK2 0x0 #define TC_CLKS_MCK8 0x1 #define TC_CLKS_MCK32 0x2 #define TC_CLKS_MCK128 0x3 #define TC_CLKS_MCK1024 0x4

#define TC_CLKS_SLCK 0x4

#define TC_CLKS_XC0 0x5 #define TC_CLKS_XC1 0x6 #define TC_CLKS_XC2 0x7

#define TC_COVFS 0x1 /* Counter Overflow Status */ #define TC_LOVRS 0x2 /* Load Overrun Status */ #define TC_CPAS 0x4 /* RA Compare Status */ #define TC_CPBS 0x8 /* RB Compare Status */ #define TC_CPCS 0x10 /* RC Compare Status */ #define TC_LDRAS 0x20 /* RA Loading Status */ #define TC_LDRBS 0x40 /* RB Loading Status */ #define TC_ETRGS 0x80 /* External Trigger Status */ #define TC_CLKSTA 0x10000 /* Clock Status */ #define TC_MTIOA 0x20000 /* TIOA Mirror */ #define TC_MTIOB 0x40000 /* TIOB Status */

static int count;

static void ledInit(void) { PIOA_PER = 0x0000000F; PIOA_OER = 0x0000000F; }

static void ledOn(void) { PIOA_CODR = 0xF; }

static void ledOff(void) { PIOA_SODR = 0xF; }

void timer_irq_handler(void) __attribute__ ((interrupt ("IRQ")));

void timer_irq_handler(void) { TC0_SR; if (count++ & 1) ledOn(); else ledOff();

// Signal end of interrupt AIC_EOICR = 0; }

int main(void) { ledInit();

// Put LDR PC, [PC, #-0xF20] instruction into IRQ vector in order to use // hardware interrupt vectoring. *(volatile unsigned int *)0x00000018 = 0xE51FFF20;

// Set up timer interrupt __ARMLIB_enableIRQ(); AIC_IDCR = 1 << TC0_ID; AIC_SVR(TC0_ID) = (unsigned)timer_irq_handler; AIC_SMR(TC0_ID) = AIC_SRCTYPE_INT_LEVEL_SENSITIVE; AIC_ICCR = 1 << TC0_ID; AIC_IECR = 1 << TC0_ID;

// Set up timer PMC_PCER = 1 << TC0_ID; // Enable T0 peripheral clock TC0_CCR = TC_CLKDIS; TC0_IDR = 0xFFFFFFFF; TC0_CMR = TC_CLKS_MCK128; TC0_IER = TC_COVFS; TC0_CCR = TC_CLKEN | TC_SWTRG;

while (count < 5);

return 0; }

Reply to
bullet
Loading thread data ...

Czy ten kompilator (lub loader kodu, w "dużych" systemach operacyjnych czasem robi to sam mechanizm mapowania pamięci wirtualnej) domyślnie zeruje zmienne statyczne o niezade- klarowanej wartości?

...bo wykorzystywanie automatycznego zerowania "dobrym programowaniem" akurat nie jest (ze względu na przenośnośc) co nie musi przeszkadzac temu, że działa ;)

pzdr, Gotfryd

Reply to
Gotfryd Smolik news

Gotfryd Smolik news pisze:

Chyba standard ANSI C tego wymaga i nie spotkałem się jeszcze z kompilatorem C, który by nie zerował automatycznie (w kodzie tzw. "C startup") niezainicjowanych zmiennych globalnych czyli w przypadku gcc sekcji ".bss".

Reply to
Adam Dybkowski

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.