Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[ARM] Enabling GPIO through registers in FriendlyARM mini2440 board

Status
Not open for further replies.

hale2bopp

Newbie level 1
Newbie level 1
Joined
Mar 8, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,329
I want to write to a physical address to change the voltage of a pin using an ARM board- but in order to write to a physical address, I need to take a virtual address, and map it to the physical address using mmap. So I did that, in this way:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
#include <fcntl.h>
#include <ctype.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/mman.h>
 
#define MAP_SIZE 4096UL
#define MAP_MASK (MAP_SIZE - 1)
 
int main(void) {
int fd;
int *map_base_c,*map_base_d, *map_base_p, *virt_addr;
off_t target,control,data,pullup;
 
control=0x56000050;
 
if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) FATAL;
 
map_base_d = mmap(0, MAP_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd,data & ~MAP_MASK);
 
printf("Memory mapped at address %p.\n", map_base_d);
 
virt_addr = map_base_d; //+ (data & MAP_MASK)
*virt_addr = 0x00;  //This is where it goes off. find out why!!!
printf("Value at address 0x%X (%p): 0x%X\n", data, virt_addr,(*virt_addr));
 
close(fd);
return 0;
}



But, The pin didn't get a high voltage as I'd expected. Is there something wrong with the way I'm changing the address? Also, is there a way to see the physical address which was mapped to the virtual address? Thanks!
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top