embeded/ARM2012. 4. 13. 11:14
엑셀을 이용한 꽁수.
아무튼 100ms 250ms 500ms 1000ms 4개를 돌리는데
아무래도 한시간에 몰아치기 하면 시간 정확도도 떨어지고 그럴테니
최대한 분산해주려고 해도 이정도 밖에 못하겠네 ㅠ.ㅠ

void Timer0A_Handler(void)		// Timer0A - internal timer
{
	TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT);

	count_10ms++;

	if ((count_10ms + 75) %  100 == 0)		{TimeService_100ms();}
	if ((count_10ms +  1) %  250 == 0)		{TimeService_250ms();}
	if ((count_10ms + 50) %  500 == 0)		{TimeService_500ms();}
	if ((count_10ms + 25) % 1000 == 0)		{TimeService_1000ms();	count_10ms = 0;}
}



'embeded > ARM' 카테고리의 다른 글

HibernateRTCSet  (0) 2012.04.19
KEIL Program Size 항목별 의미  (0) 2012.04.19
ti lm3s 시리즈 하이버네이트 모드 + RTC 사용하기  (2) 2012.04.04
TI LM3S1607 time epoch  (0) 2012.03.27
H-JTAG 에러이유?  (0) 2012.03.23
Posted by 구차니
embeded/ARM2012. 4. 4. 10:04
stellarisware를 설치하면 기본적으로 추가되는 예제를 추려내서 테스트 해보면 되는데,
대부분의 장비들이 굳이 하이버네이트 모드로 들어가는 행동을 취할수 없을때가 있다.
항상 켜져있어야 하는 장비인데, 언제꺼질지 모르지만 시간은 유지해야 한다면
하이버네이트 모드를 들어갈수 있는 시점을 정할수 없기 때문에 항상 하이버네이트 모드를 켜주면 된다.

C:\StellarisWare\boards\ek-lm3s1968\hibernate\hibernate.c
파일을 참고해서 추려내자면
static void SetRTCFucntion(void)
{
//	time_t current_time;
//	struct tm struct_time = { 0, 0, 10, 26,2,2012 - 1900,0,0,0};
//	current_time = mktime(&struct_time);
	
	SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);
		HibernateEnableExpClk(SysCtlClockGet());
		HibernateClockSelect(HIBERNATE_CLOCK_SEL_DIV128);
		HibernateRTCEnable();
//		HibernateRTCSet(current_time);
		HibernateWakeSet(HIBERNATE_WAKE_PIN);
		HibernateRequest();
}

일단 RTC를 사용하려면 무조건 하이버네이트 장치를 사용하도록 해야한다.
    SysCtlPeripheralEnable(SYSCTL_PERIPH_HIBERNATE);

하이버네이트 모듈에 들어갈 클럭을 지정해주는데, 32.768Khz가 들어가거나 4.194304Mhz를 /128 해서 넣어주도록 한다.
    HibernateEnableExpClk(SysCtlClockGet());
    HibernateClockSelect(HIBERNATE_CLOCK_SEL_DIV128); // 4.194304 Mhz input divider to 32.768kHz

 하이버네이트 모듈에 내장된 RTC 를 사용하도록 설정하고
    HibernateRTCEnable(); 

원인은 알수 없지만 wakeup 조건을 반드시 설정해 주어야 하이버네이트 모드가 작동한다.
WAKE 핀은 NC 처리해도 작동에 이상은 없는듯 하다.
    HibernateWakeSet(HIBERNATE_WAKE_PIN); 

마지막으로 하이버네이트 모드를 들어가도록 요청한다.
    HibernateRequest(); 


RTC 시간은 배터리가 소진된 시점의 마지막 시간이 다음 부팅시까지 유지된다.

'embeded > ARM' 카테고리의 다른 글

KEIL Program Size 항목별 의미  (0) 2012.04.19
타이머 핸들러 시간 충돌 안나게 조절하기?  (0) 2012.04.13
TI LM3S1607 time epoch  (0) 2012.03.27
H-JTAG 에러이유?  (0) 2012.03.23
KEIL MDK(ARM)에 H-JTAG 사용하기  (0) 2012.03.23
Posted by 구차니
embeded/ARM2012. 3. 27. 16:38

실험적으로 1900인건 찾았는데 음..

일단 아래의 메뉴얼은 deprecated 된 녀석이라 현재 버전의 stellarisware에는 존재하지 않는 내용이고

[링크 : http://www.ti.com/lit/ug/spmu063/spmu063.pdf]


KEIL MDK에서 epoch 관련 검색을 해보고는 있지만 딱히 눈에 띄지 않고 있다.

그나저나 이런 epoch가 라이브러리 차이라면..

MDK냐 code sorcery냐 codered 냐에 따라서도 다를수 있다는 의미이려나?


2012/03/27 - [Linux] - localtime() 과 mktime()을 이용하기


Posted by 구차니
embeded/ARM2012. 3. 23. 10:16
리셋이 안된다고 배째는데
아무튼 TAP 값은 맞으니까 칩 종류를 받아오는 것일테고 -_-
의심이 가는건 nTRST 연결 상태?

  • nSRST bi-directional (open collector)
    This pin serves two purposes. It can be used by the adapter to reset the target board, which is most useful during remote debugging. Furthermore, the adapter is able to detect that the reset is triggered on the target by another event, like pressing the reset button or a watchdog timeout.
  • nTRST from adapter to target
    According to the JTAG standard, the TAP controller is reset to a known state by keeping TMS high for five consecutive TCK cycles. However, some targets have problems with this sequence and thus require a hardware reset, which is marked optional in the IEEE specification. On several chips, like the AT91R40008 used on Ethernut 3, nSRST and nTRST are internally tied together. The disadvantage with this design is, that you can’t trigger a breakpoint immediately after a target hardware reset. If this signal is not used on the target, it is recommended to pull up this line with 10kOhm.
[링크 : http://www.jtagprogrammer.com/jtag-signals/]
2010/06/26 - [embeded/ARM] - ARM JTAG - Wiggler 14pin , 20pin pinout

arm 설명에서는 반드시있을 이유는 없지만, 하는걸 권장한다고 한다.
2012/03/23 - [embeded/ARM] - KEIL MDK(ARM)에 H-JTAG 사용하기

[링크 : http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka3887.html]
    [링크 : http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka3894.html] nTRST 
    [링크 : http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka3895.html] nSRST

nTRST는 Target ReSeT 인거 같은데
nSRST는 무슨 리셋이려나? 
Posted by 구차니
embeded/ARM2012. 3. 23. 09:50
MDK with Wiggler parallel jtag

Step 1. H-JTAG을 설치하고 메뉴에서 ToolConf 를 실행한다.
           기본값대로 KEIL MDK를 설치했다면 "C:\Keil" 경로를 선택한다.


Step 2. Utilities 와 Debug 탭에서 Target Driver를 H-JTAG 으로 변경한다.



Step 3. H-JTAG를 실행하여 tray에 들어갔는지 확인한다.
          H-JTAG 프로그램을 실행하지 않은 상태라면 아래와 같은 에러가 발생한다.


Step 4. 굽는다.




그런데 회사에서 사용하는 보드가 JTAG 케이블이 잘못 연결되었는지
장치 인식은 되지만 TAP configuration을 확인하라면서 정작 구워지지는 않는다.


[링크 : http://www.hjtag.com/en/upimg/H-JTAG%20USER%20MANUAL%20(EN).rar]
2012/01/27 - [embeded/ARM] - Cortex-M3 LM3S1968 Evaluation board

'embeded > ARM' 카테고리의 다른 글

TI LM3S1607 time epoch  (0) 2012.03.27
H-JTAG 에러이유?  (0) 2012.03.23
lm flash example  (0) 2012.03.13
TI LM3S 시리즈 특징 - hibernate module / non-volatile memory  (0) 2012.03.06
arm-linux-gcc 와 arm-elf-gcc의 차이점  (2) 2012.01.16
Posted by 구차니
embeded/ARM2012. 3. 13. 07:47
TI LM 시리즈(?)에서 플래시 EEPROM은 별도로 존재하지 않고
프로그램 영역의 write protect를 해제하고 프로그램이 없는 영역을 임의로
삭제/읽음으로서 EEPROM을 흉내낼수 있다.

읽는 방법은 0x0000 0000 에서 0x0001 FFFF 까지 (lm3s1607 기준 128KB FLASH)
포인터 변수를 이용하거나 직접 번지로 읽으면 된다.
*(0x00000000) 하면 bin 파일의 첫 글자인 0xB0가 보인다.

쓰는건 아직 안해봐서.. 패스?! ㅋㅋ

[링크 : http://irmus.tistory.com/entry/%EB%82%B4%EC%9E%A5-flash-%EB%A9%94%EB%AA%A8%EB%A6%AC]
[링크 : http://mycortex.springnote.com/pages/2110058 ] 
[링크 : http://www.withrobot.com/entry/myCortex-LM8962]
 
---
2012.3.27 추가
char Flash_read(unsigned int *addr, char *data, int len)
{	// addr - sizeof(char) addressing (1 byte width)
		memcpy(	data, addr, len);
}

char Flash_write(unsigned int *addr, char *data, int len)
{	//	addr - sizeof(long) addressing(4 byte width)
		FlashErase((unsigned long)addr);
		FlashProgram((unsigned long*)data, (unsigned long)addr, len);
}

char Flash_unProtect(unsigned int *addr)
{
	return FlashProtectSet((unsigned long)addr, FlashReadWrite);
}

char Flash_Protect(unsigned int *addr)
{
	return FlashProtectSet((unsigned long)addr, FlashReadOnly);
}

char Flash_Erase(unsigned int *addr)
{
	return FlashErase((unsigned long)addr); // & 0x0000FC00
}


'embeded > ARM' 카테고리의 다른 글

H-JTAG 에러이유?  (0) 2012.03.23
KEIL MDK(ARM)에 H-JTAG 사용하기  (0) 2012.03.23
TI LM3S 시리즈 특징 - hibernate module / non-volatile memory  (0) 2012.03.06
arm-linux-gcc 와 arm-elf-gcc의 차이점  (2) 2012.01.16
winARM  (0) 2012.01.12
Posted by 구차니
embeded/ARM2012. 3. 6. 09:55
ATMEL AVR을 쓰면 EEPROM이 있어서 무언가 저장할 공간이 있었는데
TI LM3S 시리즈를 보니 스펙상으로는 EEPROM이 존재를 하지 않는다.
편법일수도 있고, 가능할진 모르겠지만, 256byte의 NV memory가 존재하니 대신 사용해도 될듯?

10 Hibernation Module
10.1 Introduction

The Hibernate API provides a set of functions for using the Hibernation module on the Stellaris
microcontroller. The Hibernation module allows the software application to cause power to be
removed from the microcontroller, and then be powered on later based on specific time or a signal
on the external WAKE pin. The API provides functions to configure wake conditions, manage
interrupts, read status, save and restore program state information, and request hibernation mode.
Some of the features of the Hibernation module are:

32-bit real time clock
Trim register for fine tuning the RTC rate
Two RTC match registers for generating RTC events
External WAKE pin to initiate a wake-up
Low-battery detection
64 32-bit words of non-volatile memory
Programmable interrupts for hibernation events
This driver is contained in driverlib/hibernate.c, with driverlib/hibernate.h containing the API definitions for use by applications.  


아무튼 NVRAM을 사용하기 위한 함수는 다음과 같다. 
void HibernateDataGet (unsigned long ∗pulData, unsigned long ulCount)
void HibernateDataSet (unsigned long ∗pulData, unsigned long ulCount) 

---
2012.3.7 추가


hibernate module이 없는 모델도 있으니 주의!

'embeded > ARM' 카테고리의 다른 글

KEIL MDK(ARM)에 H-JTAG 사용하기  (0) 2012.03.23
lm flash example  (0) 2012.03.13
arm-linux-gcc 와 arm-elf-gcc의 차이점  (2) 2012.01.16
winARM  (0) 2012.01.12
ARM infocenter  (0) 2011.12.10
Posted by 구차니
embeded/AVR (ATmega,ATtiny)2012. 2. 20. 23:20
AVR 에서도 I2C는 open drain으로 구성되는데
i2c 기능을 사용하지 않고,  GPIO로 구성해서 i2c 통신을 할 경우에는
i2c 버스 풀업과 avr pin 내장 풀업으로 인해 모종의 문제가 발생하는 듯하다.

• INT1/SDA – Port D, Bit 1
INT1, External Interrupt source 1. The PD1 pin can serve as an external interrupt source to the MCU.
SDA, Two-wire Serial Interface Data: When the TWEN bit in TWCR is set (one) to enable the
Two-wire Serial Interface, pin PD1 is disconnected from the port and becomes the Serial Data
I/O pin for the Two-wire Serial Interface. In this mode, there is a spike filter on the pin to sup-
press spikes shorter than 50 ns on the input signal, and the pin is driven by an open drain driver
with slew-rate limitation.
 
•INT0/SCL – Port D, Bit 0
INT0, External Interrupt source 0. The PD0 pin can serve as an external interrupt source to the MCU.
SCL, Two-wire Serial Interface Clock: When the TWEN bit in TWCR is set (one) to enable the
Two-wire Serial Interface, pin PD0 is disconnected from the port and becomes the Serial Clock
I/O pin for the Two-wire Serial Interface. In this mode, there is a spike filter on the pin to sup-
press spikes shorter than 50 ns on the input signal, and the pin is driven by an open drain driver
with slew-rate limitation. 

Electrical Interconnection
As depicted in Figure 86, both bus lines are connected to the positive supply voltage through
pull-up resistors. The bus drivers of all TWI-compliant devices are open-drain or open-collector.
This implements a wired-AND function which is essential to the operation of the interface. A low
level on a TWI bus line is generated when one or more TWI devices output a zero. A high level
is output when all TWI devices tri-state their outputs, allowing the pull-up resistors to pull the line
high. Note that all AVR devices connected to the TWI bus must be powered in order to allow any bus operation. 
The number of devices that can be connected to the bus is only limited by the bus capacitance
limit of 400 pF and the 7-bit slave address space. A detailed specification of the electrical char-
acteristics of the TWI is given in “Two-wire Serial Interface Characteristics” on page 322. Two
different sets of specifications are presented there, one relevant for bus speeds below 100 kHz,
and one valid for bus speeds up to 400 kHz. 

'embeded > AVR (ATmega,ATtiny)' 카테고리의 다른 글

attiny2313과 함께하는 지랄같은 주말 -_-  (0) 2013.06.29
0으로 나누면 어떻게 될까?  (0) 2012.07.04
AVR ISP 핀 순서  (0) 2012.01.22
AVT FFT + DAC = 보청기?  (0) 2012.01.18
AVR TWI 예제  (0) 2012.01.11
Posted by 구차니
embeded/Cortex-M3 Ti2012. 2. 20. 21:19
어떤 i2c 칩이랑 avr이랑 통신하려니 안되서 ti 칩으로 바꾸고 나니 잘되는데 -_-
이제야 와서 이유를 찾아보게 되는데..

TI 칩에서 I2C로 Alternative Function을 사용하게 되면 open drain으로 설정되는데, 
아마도 AVR atmel 은 pull-up이 되면서 모종의 문제가 발생하는 듯하다.

 When using the I2C module, in addition to configuring the pin to open drain, the GPIO Alternate Function Select (GPIOAFSEL) register bits for the I2C clock and data pins should be set to 1 (see examples in “Initialization and Configuration” on page 185).  

15.2 Functional Description
Each I2C module is comprised of both master and slave functions which are implemented as separate peripherals. For proper operation, the SDA and SCL pins must be connected to bi-directional open-drain pads. A typical I2C bus configuration is shown in Figure 15-2 on page 399. See “Inter-Integrated Circuit (I2C) Interface” on page 546 for I2C timing diagrams. 

[링크 : http://cooa.tistory.com/entry/20030676476]
Posted by 구차니
embeded/Cortex-M3 Ti2012. 2. 5. 22:08
driverlib 관련 분석 내용 / uart 예제사용
전반적으로 초기화 설정을 보면 무언가.. 중복되도록 설정하는 느낌?
특히 UART의 경우에는 몇단계를 통해서 설정을 하는 것을 보면...

함수설명
extern void SysCtlClockSet(unsigned long ulConfig); // 클럭설정을 하도록 함.
 

extern void SysCtlPeripheralEnable(unsigned long ulPeripheral); // 포트를 사용하도록 설정함
extern void GPIOPinConfigure(unsigned long ulPinConfig); // GPIO로 쓸지 하드웨어 내장 기능을 쓸지 설정함

extern void GPIOPinTypeGPIOInput(unsigned long ulPort, unsigned char ucPins); // 해당 포트의 해당핀을 입력용으로 설정
extern void GPIOPinTypeGPIOOutput(unsigned long ulPort, unsigned char ucPins); // 해당 포트의 해당핀을 출력용으로 설정
extern void GPIOPadConfigSet(unsigned long ulPort, unsigned char ucPins, unsigned long ulStrength, unsigned long ulPadType);
                                                                                  // 해당 포트의 해당핀에 대한 GPIO 드라이브 전류와 pull-up / open-drain 설정
 

예제설명
int main(void)
{
    char cThisChar;

    // 시스템 클럭설정
    SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_OSC|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
    // UART0 기능을 사용하도록 함
    SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
    // UART 핀이 포함된 GPIOA 포트를 사용하도록 함
    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
    // GPIO A의 0번 핀을 U0 RX로 사용하도록 함
    GPIOPinConfigure(GPIO_PA0_U0RX);
    // GPIO A의 1번 핀을 U0 TX로 사용하도록 함
    GPIOPinConfigure(GPIO_PA1_U0TX);
    // GPIO A의 0번 1번 핀을 UART에 할당함
    GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);
    // UART의 클럭소스와 Baudrate등을 설정함
    UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
                       (UART_CONFIG_WLEN_8|UART_CONFIG_STOP_ONE|UART_CONFIG_PAR_NONE));
    do
    {
        // UART0로 부터 1문자를 받아옴(blocking 방식)
        cThisChar = UARTCharGet(UART0_BASE);
        // 받아온 문자을 UART0로 출력함
        UARTCharPut(UART0_BASE, cThisChar);
    } while((cThisChar != '\n') && (cThisChar != '\r'));

    return(0);
}

'embeded > Cortex-M3 Ti' 카테고리의 다른 글

uart 인터럽트 / 폴링 충돌  (0) 2012.06.18
Ti lm3s1968 arm cortex m3 i2c  (0) 2012.02.20
Cortex-M3 인터럽트 관련 문서  (0) 2012.01.31
Cortex-M3 예제소스  (0) 2012.01.27
Cortex-M3 LM3S1968 Evaluation board  (0) 2012.01.27
Posted by 구차니