embeded/Cortex-M3 Ti2012. 11. 6. 14:56
근 일주일을 골머리 아프게 만든 녀석...
데이터를 저장하는데 귀찮아서 몇단계 래핑해버리고 쓰다보니
그리고 정말정말 운이좋게 4의 배수로 저장이 되서 티가 안났었는데
이번에 프로그램을 수정/확장하다가 우연히 발견.. -_-

아무튼, LM3S에서(cortex-m3) FlashProgram()을 통해서 내장 플래시에 데이터를 써넣을때
4바이트 align이 되지 않으면 미치거나 죽는다 -_- (무한루프 돌고 있을지도?)
어쩌면 쓰긴 쓰는데 개비지 값이 이상한데로 튀어서 SRAM 영역 건드리는게 아닐까 싶을 정도..

10.2.2.8 FlashProgram
Programs flash.
Prototype:
long FlashProgram(unsigned long *pulData, unsigned long ulAddress, unsigned long ulCount)
Parameters:
pulData is a pointer to the data to be programmed.
ulAddress is the starting address in flash to be programmed. Must be a multiple of four.
ulCount is the number of bytes to be programmed. Must be a multiple of four.
Description:
This function programs a sequence of words into the on-chip flash. Each word in a page of
flash can only be programmed one time between an erase of that page; programming a word
multiple times results in an unpredictable value in that word of flash.
Because the flash is programmed one word at a time, the starting address and byte count
must both be multiples of four. It is up to the caller to verify the programmed contents, if such
verification is required.
This function does not return until the data has been programmed.
Returns:
Returns 0 on success, or -1 if a programming error is encountered.  

Posted by 구차니
embeded/Cortex-M3 Ti2012. 6. 28. 22:00
기본제공 되는 예제에서 unsigned 만 삭제하면 문제없이 영하에 대해서도 작동한다.

long GetTemperature(char isCelcius)
{
	long ulADC0_Value[1];
	long ulTemp_ValueC;
	long ulTemp_ValueF;
	
	ADCProcessorTrigger(ADC0_BASE, 3);
	while(!ADCIntStatus(ADC0_BASE, 3, false))
	{
	}

	ADCSequenceDataGet(ADC0_BASE, 3, ulADC0_Value);
	ulTemp_ValueC = ((1475 * 1023) - (2250 * ulADC0_Value[0])) / 10230;
	ulTemp_ValueF = ((ulTemp_ValueC * 9) + 160) / 5;

	if(isCelcius) return ulTemp_ValueC;
	return ulTemp_ValueF;
}
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 구차니