embeded/Cortex-M3 Ti2017. 3. 27. 10:52

UART Flag에 BUSY는

어라? 전송에 대한 것?

UART Busy
When this bit is 1, the UART is busy transmitting data. This bit remains set until the complete byte, including all stop bits, has been sent from the shift register. This bit is set as soon as the transmit FIFO becomes non-empty (regardless of whether UART is enabled).
  




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

lm3s 부트로더  (0) 2017.11.21
JTAG / SWD 핀 연결방법 조사..  (0) 2017.04.04
lm3s1607 uart pull up 문제  (0) 2017.03.24
ti cortex-m3 driverlib - UARTConfigSetExpClk()  (0) 2017.03.23
lm3s1607 uart baudrate runtime change  (0) 2017.03.15
Posted by 구차니
embeded/raspberry pi2017. 3. 25. 15:36

라즈베리 완전체(?) 햇을 만들려고 하다가 망했어 ㅠㅠ


점퍼 연결해서 쓰기 귀찮아서

대충 만능보드 이용해서 만들려고 하다가 또 실패인가...

아무튼 DHT-11은 노릇노릇하게 익어버렸고

머가 문제인지 멘붕..

다행히도 라즈베리 쪽은 손상이 없는거 같긴한데

가속도 센서 / 초음파 거리 센서는 살아있는지 확인을 해야 할 듯 ㅠㅠ




DHT-11 센서 분해하니 안쪽에 이런식으로 온도/습도 센서 부분이 있고

여기를 자세히 보면 강우 센서가 아주 미세한 모양을 한것 처럼 중앙 부분에 있다.


뒤에는 하나도 안써있어서 무슨 칩인지 알수 없으나.. 마이컴이 아닐까 생각된다.


태워먹고는 멘붕와서 만든 보드도 확 버려 버릴까 고민 ㅠㅠ

'embeded > raspberry pi' 카테고리의 다른 글

레트로 파이.. 준비(?)  (0) 2017.08.07
rpi pwm markspace balanced mode waveform  (0) 2017.06.29
라즈베리 파이 포트 요약  (0) 2017.03.25
라즈베리 파이 gpio sysfs  (0) 2017.02.15
라즈베리 파이 + 태양전지!  (0) 2017.01.25
Posted by 구차니
embeded/raspberry pi2017. 3. 25. 13:11

예전에 iot로 검색해서 보다 보니 귀찮고 헷갈려서 다시 정리

PWM은 2개 포트뿐이니.. 동시에 두개가 한계겠네..




rpi.pdf


Posted by 구차니
embeded/Cortex-M3 Ti2017. 3. 24. 10:58

얘랑은 좀 다른 이야기인데...

rs232 to rs485로 쓰다 보니

485쪽은 TXEN 하면 RX쪽이 Hi-Z로 설정되면서

아마도 0x00으로 들어 오는 듯?


그리고 driverlib에도 RX만 disable 시키는 건 없으니

함수를 하나 만들어서 RX만 disable enable을 시켜서 일단 우회

void

UARTDisable(uint32_t ui32Base)

{

    //

    // Check the arguments.

    //

    ASSERT(_UARTBaseValid(ui32Base));


    //

    // Wait for end of TX.

    //

    while(HWREG(ui32Base + UART_O_FR) & UART_FR_BUSY)

    {

    }


    //

    // Disable the FIFO.

    //

    HWREG(ui32Base + UART_O_LCRH) &= ~(UART_LCRH_FEN);


    //

    // Disable the UART.

    //

    HWREG(ui32Base + UART_O_CTL) &= ~(UART_CTL_UARTEN | UART_CTL_TXE |

                                      UART_CTL_RXE);


일단 정석(?)적인 해결책은 RX에 pull-up을 달아 주는 것

[링크 : https://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/t/45318]


OD나 PUD 안먹더라니, 직원이 push-pull로 작동한다고 하면 그런거겠지? ㅠㅠ

[링크 : https://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/t/88669]



9.2.2.27 GPIOPinTypeUART

Configures pin(s) for use by the UART peripheral.

Prototype:

void

GPIOPinTypeUART(unsigned long ulPort,

unsigned char ucPins)

Parameters:

ulPort is the base address of the GPIO port.

ucPins is the bit-packed representation of the pin(s).

Description:

The UART pins must be properly configured for the UART peripheral to function correctly. This

function provides a typical configuration for those pin(s); other configurations may work as well

depending upon the board setup (for example, using the on-chip pull-ups).

The pin(s) are specified using a bit-packed byte, where each bit that is set identifies the pin to

be accessed, and where bit 0 of the byte represents GPIO port pin 0, bit 1 represents GPIO

port pin 1, and so on.

Note:

This cannot be used to turn any pin into a UART pin; it only configures a UART pin for proper

operation. 


Posted by 구차니
embeded/Cortex-M3 Ti2017. 3. 23. 14:21

uart의 baudrate를 설정해주는 녀석은

내부적으로 UARTDisable()과 UARTEnable()을 포함하는데

UARTEnable()은 fifo enable을 포함한다.(얘가 악의 축)


그리고 UARTDisable()은 TX 할게 있으면 다 보낼때 까지 기다려주는 역활을 한다.



void

UARTConfigSetExpClk(uint32_t ui32Base, uint32_t ui32UARTClk,

                    uint32_t ui32Baud, uint32_t ui32Config)

{

    // Stop the UART.

    UARTDisable(ui32Base);


    // Set the baud rate.

    HWREG(ui32Base + UART_O_IBRD) = ui32Div / 64;

    HWREG(ui32Base + UART_O_FBRD) = ui32Div % 64;


    // Set parity, data length, and number of stop bits.

    HWREG(ui32Base + UART_O_LCRH) = ui32Config;


    // Clear the flags register.

    HWREG(ui32Base + UART_O_FR) = 0;


    // Start the UART.

    UARTEnable(ui32Base);


void

UARTEnable(uint32_t ui32Base)

{

    //

    // Check the arguments.

    //

    ASSERT(_UARTBaseValid(ui32Base));


    //

    // Enable the FIFO.

    //

    HWREG(ui32Base + UART_O_LCRH) |= UART_LCRH_FEN;


    //

    // Enable RX, TX, and the UART.

    //

    HWREG(ui32Base + UART_O_CTL) |= (UART_CTL_UARTEN | UART_CTL_TXE |

                                     UART_CTL_RXE);

}


void
UARTDisable(uint32_t ui32Base)
{
    //
    // Check the arguments.
    //
    ASSERT(_UARTBaseValid(ui32Base));

    //
    // Wait for end of TX.
    //
    while(HWREG(ui32Base + UART_O_FR) & UART_FR_BUSY)
    {
    }

    //
    // Disable the FIFO.
    //
    HWREG(ui32Base + UART_O_LCRH) &= ~(UART_LCRH_FEN);

    //
    // Disable the UART.
    //
    HWREG(ui32Base + UART_O_CTL) &= ~(UART_CTL_UARTEN | UART_CTL_TXE |
                                      UART_CTL_RXE);
}



근데 도대체!!! 뒤에 0x00은 왜 붙는거야?

Posted by 구차니
embeded/Cortex-M3 Ti2017. 3. 15. 10:07

테스트 코드

19200bps와 38400bps를 오가면서 1바이트씩 보내는 예제


  SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1);

GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);


while(1)

{

UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 19200, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE);

UARTCharPut(UART1_BASE,'A');

MDINDLY_mSec(100);

UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 38400, UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE);

UARTCharPut(UART1_BASE,'B');

MDINDLY_mSec(100);

}



근데 도대체.. 예전에는 왜 안되었던 거지??


+

추가로

FIFO 설정은 UARTConfigSetExpClk 에서 무조건 Enable 시키니 주의

Posted by 구차니
embeded/AVR (ATmega,ATtiny)2017. 2. 17. 20:11

gcc 에서는 설정이 존재하는데

영 찾아도 설정이 안보이네


[링크 : http://www.avrfreaks.net/forum/bootloader-atmega168-using-iar-compiler]


-h 옵션은 XLINK 라는 녀석에게 먹이는건데 도대체 어떻게 주는거야...

[링크 : http://www.atmel.com/Images/doc1079.pdf]

[링크 : http://supp.iar.com/FilesPublic/UPDINFO/005316/xlink.ENU.pdf]



+

_..X_FLASH_BASE 는 링커에서 넘겨주는 것 같은데

아무튼. 이 값을 기준으로 (문제는 0x000 이라는거지만) 세그먼트들의 위치가 정해지는데

문제는

-h(CODE)0-(_..X_INTVEC_SIZE-1) 

를 통해서 0x000 으로 부터 정렬하도록 되어 있어서

?FILL1 세그먼트가 생겨난다는거.. 그래서 홀로 떵그러니 0x0000 에서 존재하는데 문제가 안되려나...

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

avr bod(Brown out Detect)  (0) 2017.08.11
avr pwm 관련  (0) 2017.04.19
avr hex start addres 다시 설정이 가능할까?  (0) 2017.02.12
우리로봇기술 사이트 폐쇄  (0) 2016.08.24
avr iar __flash winavr PROGMEM  (0) 2016.07.06
Posted by 구차니
embeded/raspberry pi2017. 2. 15. 20:30

근데.. gpio 포트번호는 어떻게 매칭이 되는거지?


export에 값을 주어야 노드가 생성된다.

$ echo 11 > /sys/class/gpio/export 

$ echo out > /sys/class/gpio/gpio11/direction

$ echo 1 > /sys/class/gpio/gpio11/value

$ echo 0 > /sys/class/gpio/gpio11/value


$ echo 11 > /sys/class/gpio/unexport  

[링크 : https://sites.google.com/site/semilleroadt/raspberry-pi-tutorials/gpio]

[링크 : https://www.kernel.org/doc/Documentation/gpio/sysfs.txt]


[링크 : http://elinux.org/RPi_GPIO_Code_Samples]

Posted by 구차니
embeded/AVR (ATmega,ATtiny)2017. 2. 12. 20:07

대충보는데

링커에서 개별 오브젝트 파일의 상대주소나 절대주소를 변경해줄수 있는데

hex파일로 바뀐건 이미 링커의 결과물이라

임의로 변경은 힘들지도?


그럼 hex를 objdump로 object 파일로 덤프해서 다시 링커로 연결하면서 주소를 바꿀수 있을려나?

hex는 bin의 ascii 표현법이고

hex2bin으로 바이너리로 환원하고 다시 링커로 해주면 되려나


[링크 : http://www.avrfreaks.net/forum/how-link-bootloaderhex-applicationelf]


걍 찾아봐도 안나오는거 봐서는.. 그리 권장할 만한 아이디어가 아닌건가?

아니면 리버스목적이 아닌 이상 쓸모가 없는 방법이라서 그런걸까?

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

avr pwm 관련  (0) 2017.04.19
IAR AVR은 start section 설정이 안되나?  (0) 2017.02.17
우리로봇기술 사이트 폐쇄  (0) 2016.08.24
avr iar __flash winavr PROGMEM  (0) 2016.07.06
부품들 정리  (0) 2016.04.16
Posted by 구차니
embeded/arduino(genuino)2017. 2. 11. 12:54

그렇게 궁금해 하던 오리지널 소스 발견!


int main(void)
{
init();
initVariant();
#if defined(USBCON)
USBDevice.attach();
#endif
setup();
for (;;) {
loop();

if (serialEventRun) serialEventRun();

}
return 0;
}



[링크 : https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/main.cpp]

    [링크 : https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr/cores/arduino]


[링크 : https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr/bootloaders] AVR기반

[링크 : https://github.com/arduino/ArduinoCore-samd/tree/master/bootloaders/zero] ARM기반


2016/03/28 - [embeded/arduino(genuino)] - 아두이노 빌드 프로세스 & c/cpp



+

간단하게 말해서.. FT232 USB to RS232 칩에서 DTR를 감지하면 자동으로 리셋을 걸어버린다.

그런 이유로 아두이노 부트로더에만 업로드 하는 것이 있고,

아두이노 sketch쪽 스켈레톤 코드에는 특정 코드에서 리부팅 하는 부분이 없다.


Since the DTR signal goes from 5V to 0 at the moment a new connection to the Arduino is started, if you send this signal to the reset line of the Arduino's processor, it resets. 

[링크 : http://www.instructables.com/id/Overview-the-Arduino-sketch-uploading-process-and-/]


Data Terminal Ready (DTR) is a control signal in RS-232 serial communications, transmitted from data terminal equipment (DTE), such as a computer, to data communications equipment (DCE), for example a modem, to indicate that the terminal is ready for communications and the modem may initiate a communications channel.

[링크 : https://en.wikipedia.org/wiki/Data_Terminal_Ready]

[링크 : https://www.arduino.cc/en/uploads/Main/ArduinoNano30Schematic.pdf]


대충보면.. Makefile에서 sketch를 c로 변경해서 빌드할때 .text 섹션을 BOOT_START 주소로 옮기고 링킹하는 듯?


$ vi /usr/share/arduino/hardware/arduino/bootloaders/caterina/Makefile

#---------------- Linker Options ---------------- # -Wl,...: tell GCC to pass this to linker. # -Map: create map file # --cref: add cross reference to map file LDFLAGS = -Wl,-Map=$(TARGET).map,--cref LDFLAGS += -Wl,--section-start=.text=$(BOOT_START) LDFLAGS += -Wl,--relax LDFLAGS += -Wl,--gc-sections LDFLAGS += $(EXTMEMOPTS) LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) #LDFLAGS += -T linker_script.x








-Wl,--section-start=.bootloader=0x1E000 

[링크 : http://www.atmel.com/webdoc/AVRLibcReferenceManual/FAQ_1faq_reloc_code.html]

'embeded > arduino(genuino)' 카테고리의 다른 글

릴레이로 AC전원 스위치하기  (0) 2017.10.26
hoverlabs 사의 hover 제품  (0) 2017.07.17
avrdude arduino  (0) 2016.12.02
pwm ppm decode  (0) 2016.11.28
arduino clcd  (0) 2016.11.25
Posted by 구차니