S3C2440 Learning 3 (Use of Basic Module 1)

Publisher:fuehrd努力的Latest update time:2016-08-01 Source: eefocusKeywords:S3C2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
If a person learns something or does something to the point of selflessness, he will become successful.

①How to implement UART output? The registers used by UART are as follows: (1) UART linear control register ULCONn, (2) UART control register UCONn, (3) UART FIFO control register UFCONn, (4) UART MODEM control register UMCONn, (5) UART receive and transmit status register UTRSTATn, (6) UART error status register UERSTATn, (7) UART FIFO status register UFSTATn, (8) UART MODEM status register UMSTATn, (9) UART transmit buffer register UTXHn, (10) UART receive buffer register URXHn, (11) UART baud rate divisor register UBRDIVn.

1. The clock frequency must be configured first. If the baud rate is not correct, communication will not work. A clock configuration template will be given later. First, the UART communication port has 6 wires, two power wires, and the four wires nCTS/nRTS/TXD/RXD correspond to PH0-PH3. First, set them to the second function mode through GPHCON. Use "mpll_val = (92<<12)|(1<<4)|(1);" to set the system frequency = 400MHz through MPLLCON. In addition, through the CLKDIVN clock divider control register, UCLK selection register = 0 means that the UPLL clock is set to 48MHz, which is equal to the 48MHz provided by UCLK to USB, HDIVN = 10, and CAMDIVN[9] = 0, indicating HCLK = FCL/4, PDIVN = 1, indicating PCLK = HCLK/2. OK, the frequencies provided by the system now are: FCLK = 400MHz, HCLK = 100MHz, PCLK = 50MHz, UCLK = 48MHz.

Where CAMDIVN is the camera clock divider register, DIVN_UPLL[12]=0, where FCLK=MPLLclock, HDIVN=FCLK/4=100MHz.

2. Next, initialize UART, set UART FIFO control register, set the lowest authority and close FIFO, turn off UMCON mode 0 and mode 1, and select 8 bits of data per frame by setting ULCON linear control register. Select read and write UART data buffer register interrupt request or query mode through UCON control register rUCON0 = 0x245, and enable UART to interrupt on exception. When the transmit buffer becomes empty in non-FIFO mode or the transmit buffer reaches the transmit FIFO trigger level in FIFO mode, an interrupt request is made.

3. Set the baud rate. Use UBRDIV0/1/2 to set the baud rate respectively.

4. Select the serial port number to be read. In fact, the program selects the serial port number to be read.

5. To write data, use the calling method of WrUTXH0('\r'); WrUTXH0(data); to write data.

6. The program receives and uses the interrupt flag to wait for receiving data. UTRSTAT0/1/2, shift register empty interrupt, and then reads the data in the buffer, and sends the acquired data to the hyperterminal, so that the written data can be seen on the terminal.

②How to achieve PWM modulation output?

The buzzer is controlled by GPB0, and the pin multiplexing function TOUT0 is changed to PWM output.

1. Configure the clock frequency division as above. If the frequency is too fast, you can’t hear the sound from the buzzer!

2. Set TOUT0 output, that is, set GPB0 of GPBCON to 10; then use TCFG0/TCFG1/TCNTB0/TCMPB0 to configure the PWM output frequency.

 

rTCFG0 &= ~0xff; //These two statements set the calibration value of timer 0 and 1, and the initial value of the cycle count

rTCFG0 |= 15; //prescaler = 15+1

rTCFG1 &= ~0xf; //This is to select the 8-frequency division when the MUX input is input to the PWM timer count

rTCFG1 |= 2; //mux = 1/8

 

rTCNTB0 = (PCLK>>7)/freq; //Timer 0 count buffer register, used to load the initial value of the down count, anyway, the timer is down counting

rTCMPB0 = rTCNTB0>>1; // 50% is used to compare with the value in the counter, which is also used for pulse width modulation

 

rTCON &= ~0x1f; //Timer control register, turn off dead zone, auto reload, turn off inverter, update TCNTB0/TCMPB0 initial value, turn on TIMER0

rTCON |= 0xb; //disable deadzone, auto-reload, inv-off, update TCNTB0&TCMPB0, start timer 0

rTCON &= ~2; //clear manual update bit and no longer update TCNTB0/TCMPB0.

In fact, the TCNT0 counter, which actually works the hardest, records the 8-frequency pulse from PCLK. It outputs a high level when TCNT0≤TCMPn and outputs a low level when TCNT0>TCMPn.

So what is the current cycle? Timer output clock frequency = PCLK/{prescaler value+1}/{divider value}, PCLK=50MHz, then divider value is the 8-frequency division, after the prescaler, prescaler=15, so frequency = 50MHz/16/8=390.625KHz. And what is the count value, (PCLK>>7)/freq=390625/freq, here let freq=10, that is, T=(1/390625)*39062.5=0.1S, I don't know why the TCNTB value is useless when it reaches a certain level. I forgot that this register is 16 bits and has a valid value of 65536. It is useless to increase it. It is more effective to change the previous timer output frequency.

③How to realize AD sampling?

First, select the AD channel through the ADCCON register, enable the AD conversion prescaler, write the AD conversion pre-calibration value (equivalent to these two items setting the frequency of AD conversion), and through AN0-AN7/YM/YP/XM/XP, the strange AD conversion, after the AD conversion starts, the AD start bit will change from 1->0, after the AD conversion ends, the AD end mark bit will change from 0->1, and the AD conversion result will be stored in the ADCDATA0 register. The AD of S3C2440 is 10, which can be directly taken out from ADCDAT0. Then the program involves ADCCON and ADCDATA0, the two main registers. The program directly inputs a channel and returns an AD value. The other is the AD clock. When configuring the system clock, choose to assign a frequency reference. IICCON is the I2C bus control register.

④How to implement IIC reading and writing?

Whether it is hardware or software processing, I2C is to build an I2C timing to meet hardware communication and finally realize communication. Although it is simple, it is still analyzed from the register and timing. The IICDS register is used. It is the first address of the IIC device to be written or read, but it must be assigned before starting the IIC transmission; the IICSTAT register is used to start IIC communication, and then the IIC control bus is enabled through IICCON, the ACK function of the IIC bus is enabled, the Tx/Rx interrupt is enabled, and the IICCLK frequency is set, rIICCON = 0xaf;. At present, this program uses a register to mark the status. After reading or writing, the program will fall into while waiting. Then the specific status can only be checked through the interrupt, and the value of that register is updated to make the program jump out of while.

⑤How to create a project in ADS, how to create a new program, how to compile and how to simulate?

ADS is actually software launched by ARM. ADS consists of command line development tools, ARM runtime libraries, GUI development environment (Code Warrior and AXD), and utility support software. The command line development tool completes the source code compilation and linking into executable code. The ARM runtime library is mainly used to support compiled C and C++ code. CodeWarrior for ARM is a complete set of integrated development tools that fully utilizes the advantages of ARM RISC. The tool is designed for ARM RISC-based processors. AXD is an ARM extended debugger.

⑥ "C language" variable number of variables? ?

The macros va_arg(), va_start(), and va_end() are used together to allow a function to take a variable number of arguments. A typical example of a function that takes a variable number of arguments is printf(). The type va_list is defined in . The general procedure for creating a function that takes a variable number of arguments is: In the function definition, the variable argument list must be preceded by one or more known parameters, the rightmost of which is last_parm. The name of last_parm is used as the second argument in the call to va_start(). Before any variable length arguments are accessed, the argument pointer argptr must be initialized with va_start(). After argptr is initialized, the argument is returned as the argument type of the next argument after a call to va_arg(). Finally, after all arguments have been taken and before returning from the function, va_end() must be called. This ensures that the stack is properly restored. If va_end() is not used correctly, the program may crash.

Keywords:S3C2440 Reference address:S3C2440 Learning 3 (Use of Basic Module 1)

Previous article:S3C2440 Study Notes 5 (Analysis of 2440slib.s source program)
Next article:S3C2440 Learning 4 (How to use Jlink)

Recommended ReadingLatest update time:2024-11-16 15:36

S3C2440 - RTC interrupt
The RTC (Real Time Clock) unit can be powered by the system backup battery when the system is powered off. The RTC can transfer 8-bit BCD data to the CPU through the ARM's STRB/LDRB instructions. The data includes hours, minutes, seconds, hours, days, months and years. The RTC can also perform alarm functions using an
[Microcontroller]
S3C2440 - RTC interrupt
S3C2440 bare metal --- NandFlash programming_timing and initialization
1. NandFlash initialization  Nandflash initialization mainly includes the setting of the timing diagram and the enabling of the Nandflash controller. Let's first look at the timing diagram in the S3C2440 chip manual. In the above figure, we have set HCLK to 100M. Then the clock cycle is 1/100M=10ns  Then the figur
[Microcontroller]
S3C2440 bare metal --- NandFlash programming_timing and initialization
s3c2440GPIO programming
1.GPIO Introduction:    GPIO (general purpose input/output port) is relative to the chip. If there are GPIO pins on the corresponding chip, the changes of the pins (i.e. the changes of the high and low levels of the pins) can be obtained by reading these pins. s3c2440 belongs to ARM920T, with a total of 130 GPIOs,
[Microcontroller]
S3C2440 ADC Analysis
1. Hardware Principle Analysis We know from the structure diagram and data sheet that the ADC module has a total of 8 channels for analog signal input, namely AIN0, AIN1, AIN2, AIN3, YM, YP, XM, XP. So how does ADC achieve the conversion from analog signal to digital signal? First, the analog signal is input from any
[Microcontroller]
S3C2440 - DMA transfer (taking character transfer as an example)
1. Advantages of using DMA and request sources supported by DMA 1. The advantage of DMA is that it does not require CPU intervention during data transmission, which can greatly improve the CPU's working efficiency. 2. DMA is very important in large-capacity data transmission, such as image data transmission, SD ca
[Microcontroller]
Video data collection based on microprocessor S3C2440 and WinCE embedded real-time operating system
With the continuous development of embedded technology, various embedded microprocessors and controllers continue to appear and are widely used in industrial control, communications, PDAs, security and other fields. The embedded microprocessor S3C2440 based on the ARM920t core has good data processing capabilities, lo
[Microcontroller]
Video data collection based on microprocessor S3C2440 and WinCE embedded real-time operating system
s3c2440#SDRAM#initialize
1. Pin Description  JZ2440 SDRAM wiring diagram   You can see that two SDRAMs are connected to the development board in parallel, with a total of 27 address lines and 32 data lines (16 each). (1) CLK: The clock that SDRAM works on, and all input signals are detected on the rising edge of CLK. That is to say, any c
[Microcontroller]
s3c2440#SDRAM#initialize
In-depth exploration of S3C2440 special function register addresses
       S3C2440 integrates a rich set of peripheral controllers (LCD controller, USB Device controller, USB Host controller, NAND FLASH controller, I2C controller, SPI controller, etc.). To control these peripherals, you need to set the registers of the corresponding controllers to generate the corresponding drive timin
[Microcontroller]
In-depth exploration of S3C2440 special function register addresses
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components
Guess you like

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号