hi all,
i am trying to use spi on at91sam9g20. on this web site
http://armbedded.eu/node/318
there are some instructions, which are compiling kernel , and making some changes on board-sam9g20.c file. i did these instructions, change my board's c file and compile kernel succesfully. But after all i cannot see /dev/spi on my board.
Are there anyone work with spi ? i really need some help.
what am i doing wrong?
thanks.
problem with using spi on sam9g20
Moderator: nferre
Post
Re: problem with using spi on sam9g20
Hallo everyone
I am having some problems with SPI on AT91SAM9G20
I am using kernel 2.6 and my target is SPI1
It is a commercial board with a 400Mhz part, but SPI1 is not supported by manufacturer, so i have to use registers
Went through the manual and did various check, but no success so far
Here is what i did
PIO register check (man pag 33): SPI1 is peripheral A on pins PB0,1,2
setdiopin does not change PB0 (MISO) so it seems there is a peripheral set there already
PIO Status Register PIO_PSR (man page 377): offset is 0x0008; base is 0xFFFF F600 (PIOB)
from shell : "devmem 0xFFFFF608 w "
i get 0x7FF80000 so peripheral is active (P13=0)
PIO AB Status Register PIO_ABSR (man page 388 ):offset is 0x0078 ;base is 0xFFFF F600 (PIOB)
from shell : "devmem 0xFFFFF678 w "
i get 0x00000000 so peripheral selected is A , correct
PMC register
Peripheral Clock Status Register PMC_PCSR (man page 302): offset is 0x0018,base is 0xFFFF FC00
from shell : "devmem 0xFFFFFC18 w "
default PCSR status is 0x003E021C (SPI1 clock is off ! )
need to write 3E221C
Peripheral Clock enable Register PMC _PCER offset is 0x0010
i only write bit 13
from shell : "devmem 0xFFFFFC10 w 0x00002000" works ! PCSR value changed
At this point i made a very simple shell script to test the basic functionality
here it is
#!/bin/bash
#SPI test script for T4200 using busybox commands
# -------------INIT-----------------
devmem 0xFFFFFC10 w 0x00002000 # enable SPI1 clock ; Peripheral Clock enable Register PMC_PCER man. pag 297
SPI1_BASE=FFFCC000 #base hex spi address
devmem $((0x$SPI1_BASE)) w 129 #reset and activate spi in slave mode; reg SPI_CR , offset=0x00 write-only
devmem $((0x$SPI1_BASE+4)) w 1 #activate spi master mode; reg SPI_MR , offset=0x04
devmem $((0x$SPI1_BASE+48)) w 0xFF02 #polarity leading edge capture, idle level low, minimum speed ; reg SPI_CSR0 man. pag 403
# -------------MAIN LOOP------------
while true
do
printf "Sending.. \n"
devmem $((0x$SPI1_BASE+12)) h 0x23 # transfer '#' ;reg SPI_TDR , offset=0x0C write-only
sleep 1
done
i also connected MISO and MOSI in a loop with a wire but nothing shows on my oscope.....
(gpio pins are working)
Any suggestion is appreciated
kind regards
I am having some problems with SPI on AT91SAM9G20
I am using kernel 2.6 and my target is SPI1
It is a commercial board with a 400Mhz part, but SPI1 is not supported by manufacturer, so i have to use registers
Went through the manual and did various check, but no success so far
Here is what i did
PIO register check (man pag 33): SPI1 is peripheral A on pins PB0,1,2
setdiopin does not change PB0 (MISO) so it seems there is a peripheral set there already
PIO Status Register PIO_PSR (man page 377): offset is 0x0008; base is 0xFFFF F600 (PIOB)
from shell : "devmem 0xFFFFF608 w "
i get 0x7FF80000 so peripheral is active (P13=0)
PIO AB Status Register PIO_ABSR (man page 388 ):offset is 0x0078 ;base is 0xFFFF F600 (PIOB)
from shell : "devmem 0xFFFFF678 w "
i get 0x00000000 so peripheral selected is A , correct
PMC register
Peripheral Clock Status Register PMC_PCSR (man page 302): offset is 0x0018,base is 0xFFFF FC00
from shell : "devmem 0xFFFFFC18 w "
default PCSR status is 0x003E021C (SPI1 clock is off ! )
need to write 3E221C
Peripheral Clock enable Register PMC _PCER offset is 0x0010
i only write bit 13
from shell : "devmem 0xFFFFFC10 w 0x00002000" works ! PCSR value changed
At this point i made a very simple shell script to test the basic functionality
here it is
#!/bin/bash
#SPI test script for T4200 using busybox commands
# -------------INIT-----------------
devmem 0xFFFFFC10 w 0x00002000 # enable SPI1 clock ; Peripheral Clock enable Register PMC_PCER man. pag 297
SPI1_BASE=FFFCC000 #base hex spi address
devmem $((0x$SPI1_BASE)) w 129 #reset and activate spi in slave mode; reg SPI_CR , offset=0x00 write-only
devmem $((0x$SPI1_BASE+4)) w 1 #activate spi master mode; reg SPI_MR , offset=0x04
devmem $((0x$SPI1_BASE+48)) w 0xFF02 #polarity leading edge capture, idle level low, minimum speed ; reg SPI_CSR0 man. pag 403
# -------------MAIN LOOP------------
while true
do
printf "Sending.. \n"
devmem $((0x$SPI1_BASE+12)) h 0x23 # transfer '#' ;reg SPI_TDR , offset=0x0C write-only
sleep 1
done
i also connected MISO and MOSI in a loop with a wire but nothing shows on my oscope.....
(gpio pins are working)
Any suggestion is appreciated
kind regards
- blue_z
- Location: USA
Post
Are you trying to hack into some product that happens to have that SoC?
If the kernel doesn't have SPI support, then you cannot hack the system to use some SPI slave device.
Regards
Re: problem with using spi on sam9g20
"2.6" really isn't specific enough. The version numbering for the Linux kernel changed at 3.0.karlzeb wrote:I am using kernel 2.6 and my target is SPI1
What does that mean?karlzeb wrote:It is a commercial board with a 400Mhz part,
Are you trying to hack into some product that happens to have that SoC?
What are you really trying to do?karlzeb wrote:Any suggestion is appreciated
If the kernel doesn't have SPI support, then you cannot hack the system to use some SPI slave device.
Regards
Post
Re: problem with using spi on sam9g20
Hallo
I am using SPI registers directly, no kernel support here; now it works anyway ; thanks !
I am using SPI registers directly, no kernel support here; now it works anyway ; thanks !
Who is online
Users browsing this forum: No registered users and 1 guest