//DO NOT USE -> Out Of Date (selectiveClearAndWrite_# better) void clearModWriteRange_word(BYTE_ADDRESS port, unsigned short offset, WORD map_32Bit, bool enable, unsigned char startBit, unsigned char size){ WORD clearBits = 0x01; int i = 0; for(i = 1; i < size; ++i) { clearBits = clearBits << 1; clearBits |= 0x01; } clearBits = clearBits << startBit; readModWrite_word(port,offset,clearBits, DISABLE); readModWrite_word(port, offset, map_32Bit, ENABLE); }
// initialize ADC0 with an interrupt // initialize GPIOD.3 for ADC0 // initialize GPTM to trigger ADC at 2ms void initRangeSensor(void) { // enable interrupts for ADC0 in the NVIC readModWrite_word(CORE_PERIPHERALS, 0x100, 0x00004000,ENABLE); // enable TIMER0A sysclk readModWrite_byte(SYSTEM_CONTROL, RCGCTIMER, 0x08,ENABLE); // enable GPIOD sysclk readModWrite_byte(SYSTEM_CONTROL, RCGCGPIO, 0x08,ENABLE); // enable ADC0 sysclk readModWrite_byte(SYSTEM_CONTROL, RCGCADC, 0x01,ENABLE); // configure GPIOF for ADC readModWrite_byte(GPIOD, 0x420, 0x08,ENABLE); readModWrite_byte(GPIOD, 0x51C, 0x08,DISABLE); readModWrite_byte(GPIOD, 0x528, 0x08,ENABLE); // configure TIMER#A for 50ms TAOTE enabled // disable TIMER3A write_word(TIMER3, 0x00C, 0); // disable timer write_word(TIMER3, 0x000, 0); // set to 32bit mode write_word(TIMER3, 0x004, 0x02); // set to periodic mode write_word(TIMER3, 0x028, 4000000); // set timer to 50ms write_word(TIMER3, 0x00C, 0x0021); // enable timer with output enable for adc // configure ADC0 write_word(ADC0, 0x000, 0); // disable ADC SS write_word(ADC0, 0x014, 0x0005); // select timer as trigger source write_word(ADC0, 0x040, 4); // select the ADC sample sequence write_word(ADC0, 0x044, 0x06); // select the ADC sample sequence to end on first sample and generate an interrupt write_word(ADC0, 0x008, 0x01); // enable interrupts to get adc data write_word(ADC0, 0x000, 0x01); // enable ADC SS }
void initTimerForDacOutput(void) { // enable interrupts for TIMER1A in the NVIC readModWrite_word(CORE_PERIPHERALS, 0x100, 0x00200000,ENABLE); // enable TIMER1A sysclk readModWrite_byte(SYSTEM_CONTROL, RCGCTIMER, 0x02,ENABLE); // configure TIMER1A write_word(TIMER1, 0x000, 0); // disable timer write_word(TIMER1, 0x004, 0x02); // set to periodic mode write_word(TIMER1, 0x028, 20000); // set timer to 250uSec write_word(TIMER1, 0x018, 0x01); // enable interrupts write_word(TIMER1, 0x00C, 0x0001); // enable timer }
void SysClk_bypassPLL (bool enable) { readModWrite_word (SYSTEM_CONTROL, RCC, BYPASS_bit, enable); }