ARM7 AIC (Advanced Interrupt Controller)

This theory of working is based on SAM7 AIC behaviour, read from AT91SAM7S Series Preliminary. AIC is an 8-level priority, maskable, vectored interrupt controller. It provides up to 32 interrupt sources. AIC drives IRQ and FIQ inputs of an ARM core. AIC inputs are driven from internal peripherals and external interrupts (e.g. IO). ARM7 AIC AIC behaviour may vary, Atmel SAM7 AIC is continuously clocked, therefore it does need to be powered up. On LPC family it is called VIC (Vectored Interrupt Controller). FIQ always is an interrupt with the highest priority and has source 0.
The moment the IRQ line to AIC is asserted the priority controller determines which interrupt should run. In the case when few interrupts with the same priority assert IRQ line the interrupt with the lowest source number is serviced first. If during interrupt service another interrupt is signaled to AIC, it is serviced only if it has higher priority than the currently pending one. If it has lower priority it is delayed until the pending interrupt is finished.
Example AIC configuration on AT91SAM7S64 for PWM (See full AIC PWM config.):

AT91C_BASE_AIC->AIC_IDCR = 0x1 << 10;
AT91C_BASE_AIC->AIC_SVR[10] = (unsigned int) audio_pwm0_isr_handler;
AT91C_BASE_AIC->AIC_SMR[10] = AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL;
AT91C_BASE_AIC->AIC_ICCR = 0x1 << 10;
CPSR Enabling Interrupt

To enable interrupt clear an I bit in CPSR register (Current Program Status Register). When I bit is set, it disables IRQs. To clear I bit (which is bit 7 in CPSR), read CPSR, make a logic and operation with 0x7F, and write it back to CPSR:

MRS R0, CPSR ; Read CPSR
AND R0, R0, #0x7F ; Clear I bit
MSR CPSR_c, R0 ; Write R0 back to CPSR

Remember, that ARM must be in privileged mode to be able to operate on CPSR. This can be done like this:

MRS R0, CPSR ; Read CPSR
BIC R0, R0, #0x1F ; Remove current mode
ORR R0, R0, #0x13 ; Enter supervisor mode
MSR CPSR_c, R0 ; Write R0 back to CPSR
CPSR Disabling Interrupt

To disable interrupt set an I bit in CPSR register (Current Program Status Register). To set I bit (which is bit 7 in CPSR), read CPSR, make a logic or with 0x80, and write it back to CPSR.

MRS R0, CPSR ; Read CPSR
ORR R0, R0, #0x80 ; Set I bit
MSR CPSR_c, R0 ; Write R0 back to CPSR

ARM7 debugging on linux with GDB and OpenOCD

First an JTAG connection using OpenOCD has to be established. Open console and type:

# openocd

If in current dictionary openocd.conf file is not found then OpenOCD will use the one from installation dictionnary. Next, open another session (we will call it JTAG session) in terminal and type (assuming port 4444):

# telnet localhost 4444

Now its time to open a GDB connection. First halt ARM using halt command in JTAG session:

# arm-elf-gdb examplefile.elf
(gdb) target remote:3333

If arm-elf-gdb is unknown then add it's installation folder to your $PATH. When opening GDB connection you have to specify a file with a symbol table e.g. ELF file. This is done by '-g' option in GCC compiler (add this option in your Makefile).

Breakpoints
To set a breakpoint just use break or b command:

(gdb) b main.c:44

This will set a breakpoint in main.c file in line 44. To run the target just type:

(gdb) continue

If you get an information that breakpoint can not be pleased because the memory in not read/write then you need to set a hard breakpoint. Go to your JTAG session and type:

> gdb_breakpoint_override hard

To delete breakpoints just type:

(gdb) delete

For CPU dump:

(gdb) info registers
r0 0x200000 2097152
r1 0x0 0
r2 0x200778 2099064
r3 0x20215c 2105692
r4 0x4040404 67372036
r5 0x5050505 84215045
r6 0x6060606 101058054
r7 0x7070707 117901063
r8 0x8080808 134744072
r9 0x9090909 151587081
r10 0x10101010 269488144
r11 0x11111111 286331153
r12 0x10592d 1071405
sp 0x203bd0 2112464
lr 0x202924 2107684
pc 0x10010c 1048844
fps 0x0 0
cpsr 0x60000093 1610612883

Configure PWM in AT91SAM7S64

In order to have PWM working following steps must me taken:

Enable interrupts
This can be done by clearing an I bit in CPSR register (Current Program Status Register). I bit disables IRQ interrupts when it is set. To clear I bit (which is bit 7), read CPSR, make a logic and operation of 0x7F with read value from the register. Next, write it back to CPSR.

asm volatile
(
"MRS R0, CPSR \n\t"
"AND R0, R0, #0x7F \n\t"
"MSR CPSR_c, R0 \n\t"
);

ARM must be in privileged mode to be able to operate on CPSR. Listing above is a macro used in C, also it could be defined as an inline function.

Configure PIO (Parallel Input/Output) Controller
Pin that will be used as a PWM (Pulse Width Modulation) output must be disabled. Next, peripheral function A has to be set:

// Confiugre PIO (Parallel Input/Output Controller).
AT91C_BASE_PIOA->PIO_PDR = AT91C_PA0_PWM0; // Enable peripheral function.
AT91C_BASE_PIOA->PIO_ASR = AT91C_PA0_PWM0; // Peripheral function A.


Power up PWM Controller
PMC (Power Management Controller) has to know to power up PWM Controller. This is done by setting Peripheral ID bit in PCER (Peripheral Clock Enable Register). In AT91SAM7S64 PWM Controller has a Peripheral ID number 10.

// Configure PMC (Power Management Controller).
AT91C_BASE_PMC->PMC_PCER = 1 << AT91C_ID_PWMC; // Power up PWM Controller.


Configure AIC (Advanced Interrupt Controller)
Interrupt source has to be selected (in following example source 10 is chosen). In AT91SAM7S64 up to 32 sources are available: FIQ (PID0), SYS (PID1), and PID2 to PID31. However, before configuring anything, corresponding bit (10 in this case) has to be set in IDCR (Interrupt Disable Command Register).
Next, an address of an ISR has to be written to AIC SVR (Source Vector Register).
Third, a priority and source type has to be set. Choice of 7 levels of interrupts priorities is given (0 - the lowest, and 7 - the highest). Source type defines whether an interrupt is triggerd on a level or an edge.
Finally, interrupt corresponding bit has to be set in AIC ICCR (Interrupt Clear Command Register).
When all is done an interrupt can be enabled in AIC IECR (Interrupt Enable Command Register) by setting corresponding bit.

AT91C_BASE_AIC->AIC_IDCR = 0x1 << 10;
AT91C_BASE_AIC->AIC_SVR[10] = (unsigned int) audio_pwm0_isr_handler;
AT91C_BASE_AIC->AIC_SMR[10] = AT91C_AIC_PRIOR_LOWEST | AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL;
AT91C_BASE_AIC->AIC_ICCR = 0x1 << 10;

However, a macro is often available from port header file (e.g. from ATMEL).

// Configure AIC (Advanced Interrupt Controller).
AT91F_AIC_ConfigureIt(10, AT91C_AIC_PRIOR_LOWEST, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL, audio_pwm0_isr_handler);
AT91C_BASE_AIC->AIC_IECR = 0x1 << 10;


Configure PWM Controller
Now it is a time to configure PWMC. First, before anything a PWM Channel has to be disabled by using PWMC DIS (Disable Register). Selecting DIVA, DIVB prescallers is made by using PWMC MR (Mode Register), however in this example they are not used.
Next, prescaller and polarisation has to be selected in PWMC CMR (Channel Mode Register). Because PWM uses 16 clock, period and duty cycle are 16 bit values set in PWMC CPRDR (Channel Period Register), and PWMC CDTYR (Channel Duty Cycle Register) respectively. When all is set the PWM Channel can be enabled in PWMC ENA (Enable Register), and interrupts from that channel can be enabled in PWMC IER (Interrupt Enable Register).

AT91C_BASE_PWMC->PWMC_DIS = AT91C_PWMC_CHID0;
AT91C_BASE_PWMC->PWMC_MR = 0; // Clear mode register.
AT91C_BASE_PWMC->PWMC_CH[0].PWMC_CMR = AT91C_PWMC_CPRE_MCK_1024 | AT91C_PWMC_CPOL; // MCK/1024 and polarity 1.
AT91C_BASE_PWMC->PWMC_CH[0].PWMC_CPRDR = 0x0000FFFF;
AT91C_BASE_PWMC->PWMC_CH[0].PWMC_CDTYR = 0x00008FFF;
AT91C_BASE_PWMC->PWMC_ENA = AT91C_PWMC_CHID0; // Enable channel 0.

// Enable interrupt.
AT91C_BASE_PWMC->PWMC_IER = AT91C_PWMC_CHID0;


Interrupt handler
In this example handler does not do anything except writing to AIC EIOCR (End Of Interrupt Command Register) to let AIC know that interrupt has been serviced.

void
audio_pwm0_isr_handler (void)
{
AT91C_BASE_AIC->AIC_EOICR = 0;
}
Start X11 system automatically in linux

To run X11 automatically in Slackware 13.0 (and many other distros) you have to edit /etc/inittab file, which may look like this:

.
.
# These are the default runlevels in Slackware:
# 0 = halt
# 1 = single user mode
# 2 = unused (but configured the same as runlevel 3)
# 3 = multiuser mode (default Slackware runlevel)
# 4 = X11 with KDM/GDM/XDM (session managers)
# 5 = unused (but configured the same as runlevel 3)
# 6 = reboot

# Default runlevel. (Do not set to 0 or 6)
id:3:initdefault:
.
.

and change line

id:3:initdefault:

to

id:4:initdefault:
Sound in Slackware

If sound in Slackware does not work type groups in console and check the output. Your user should be added in audio, devplug, power groups. If his not, then type

usermod -g oldgroup1,oldgroup2,audio,power,devplug username

where oldgroup1/2 are groups your user already belongs to.

Installing libFTDI and OpenOCD on Linux

First download libFTDI, and unpack it in your working folder. Change directory to unpacked libFTDI directory and login as a root. Now issue following commands:

make
make install

This is your libFTDI installed. Now download latest OpenOCD. Unpack it and change direcotry to where it was unpacked. Login as a root user and issue following commands:

make
make install

This was an easy part. More tricky is to tell your system to use your JTAG. However, this may be done by creating udev entry for your debugger. Simply 'touch' a file in /etc/udev/rules.d/ named 45-ft2232.rules with following entry:

BUS=="usb", ACTION=="add", SYSFS{idProduct}=="bbe0", SYSFS{idVendor}=="0403", MODE:="0666", GROUP:="usres"

This works for usbScarab from KrisTech (which is not a new debugger). To sort our your idProduct, idVendor try as root:

# lsusb
Bus 005 Device 003: ID 0403:bbe0 Future Technology Devices International, Ltd
Configure Logitech QuickCam IM/Connect on Ubuntu 10 - Skype

If you are having issues with getting your Logitech QuickCam IM/Connect working on Skype in Ubuntu 10, go to software package manager and install 'libv4l-0' library (might be done by default). Next add "env LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so" in your skype launcher (or in command line if you use it). Now your launcher entry should look something like this:

env LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so /usr/bin/skype
Repleace '/usr/bin/skype' which relevant path of skype installation on your system.

Slackware 13.0 kernel update

To update Slackware 13.0 default kernel, first download kernel from kernel.org - version that suits you. In my case 2.6.31.1:

wget http://kernel.org/pub/linux/v2.6/linux-2.6.31.1.tar.bz2
tar -jxvf linux-2.6.33.1.tar.bz2 -C /usr/src/

Now the kernel is downloaded and unpacked to /usr/src/2.6.31.1 directory. Remove link to your old kernel and link it to the new source you have just downloaded. Now you can do two things: one is to configure the kernel by ourself, or (easy option) use configuration from your current kernel. I am going to show how to do it with the easier option. Copy your config from your /boot/config-huge-2.6.29.6 (or any other) to your /usr/src/linux/

cd /usr/src/
rm linux
ln -s /usr/src/linux-2.6.33.1 /usr/src/linux
cd linux
cp /boot/config-huge-2.6.29.6 .config

Now run configuration menu, scroll down, and select option 'load config file':

make menuconfig

Now your kernel will be build with your old kernel configuration. If you are asked about some new options (old config may not cover new kernel features), answareing ENTER (default) should be ok:

make
make install_modules

Second command will install modules in /lib/modules/2.6.33.1. Now it is time to copy all files to /boot/

cp arch/x86/boot/bzImage /boot/vmlinuz-huge-2.6.33.1
cp System.map /boot/System.map.new
cd /boot/
rm System.map
ln -s /boot/System.map.new /boot/System.map

Last step is to add new entry to your /etc/lilo.conf file:

image = /boot/vmlinuz-huge-2.6.31 addappend="i8042.reset"
root = /dev/root
label = S13.0-2.6.31
read-only

Now type 'lilo' in command line and if there is no errors, reboot and see how new kernel works. The i8042.reset part in my case is added to reset keyboard driver at power up, otherwise keyboard may not respond.

Format USB memory under Linux

To format USB stick under Linux Slackware 13.0 I use following (as a root):

# dmesg | tail sd 5:0:0:0: [sdb] Mode Sense: 43 00 00 00
sd 5:0:0:0: [sdb] Assuming drive cache: write through
sd 5:0:0:0: [sdb] 3951360 512-byte hardware sectors: (2.02 GB/1.88 GiB)
sd 5:0:0:0: [sdb] Write Protect is off
sd 5:0:0:0: [sdb] Mode Sense: 43 00 00 00
sd 5:0:0:0: [sdb] Assuming drive cache: write through
sdb: sdb1
sd 5:0:0:0: [sdb] Attached SCSI removable disk
sd 5:0:0:0: Attached scsi generic sg1 type 0
usb-storage: device scan complete

From this we know that USB is mounted under /dev/sdb1/ location. Now unmount the drive e.g. 'umount /dev/sdb1' and issue following:

mkdosfs -n 'GiveIt2ME' /dev/sdb1

Comments:

Author: toem Date 2012-05-03 13:42:54

tomeksad



Author: Tyler Date 2012-04-14 08:04:43

The stuff is rather significant.



Author: Isabel Date 2012-10-05 08:53:31

What i do not understood is in truth how you are not really much more well-liked than you might be now. You're so intelligent. You realize therefore significantly on the subject of this matter, produced me in my view believe it from a lot of varied angles. Its like men and women are not interested unless it is something to do with Lady gaga! Your personal stuffs great. All the time take care of it up!



Author: Kristie Date 2012-10-05 08:52:54

What i do not understood is in truth how you are not really much more well-liked than you might be now. You're so intelligent. You realize therefore significantly on the subject of this matter, produced me in my view believe it from a lot of varied angles. Its like men and women are not interested unless it is something to do with Lady gaga! Your personal stuffs great. All the time take care of it up!



Author: Mohammad Date 2012-04-02 08:02:36

Everything is very open with a really clear explanation of the challenges. It was really informative. Your site is very helpful. Many thanks for sharing!



Author: Blake Date 2012-03-29 14:29:37

I think the admin of this web page is actually working hard in support of his web page, for the reason that here every stuff is quality based data.



Author: cialis Date 2012-03-01 19:41:27

Faites attention aux plantes des entreprises ou ses.



Author: elundleslee Date 2011-12-16 11:10:59

check this link, , for special offer to your friends



Author: Дизайн интерьера Москва Date 2011-10-21 09:50:23

sait - Дизайн интерьера в Москве



Author: bt Date 2011-08-09 16:52:01

kontroler phy DP83848 STE100P



Add Comment:

Name:


Comment: