Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

SPI port init for Bascom

2004-12-02 by John Allen

Hi Gang..!!

  Does anyone have any example Bascom code demoing the proper init 
and use of the hardware based SPI. I have the OLIEMEX MT128 demo 
board and ISP dongle as well, to connect to Bascom. I downloaded the 
PDF scat's and carefully wired up an add-on board to carry the 
signals from the connectors. I used a carrer board from Sparkfun 
Electronics to get the 8 pin LAP package of the Atmel AT25P1024C 
Flash SPI chip large enough to mount on a normal 100 center proto 
board. For the Atmega 128, MI is pin 13 PB3, MO is pin 12 PB2, SCK 
is pin 11 PB1 and SS is pin 10 PB0. I double checked the wiring to 
the slave Atmel chip. I am using a scope to view the control pins. 
Tests show that the firmware is not properly generating the SS 
signal or SCK signal. They just stay high. I have connected a jumper 
clip to ground and have touched it to the MI pin during the test and 
it does change the input data returned from Hex FF to 00. So I think 
the internal SPI routines are doing sonething, but the other pins 
are just not initing correctly... 

   Before I got the MT128 board, I also had the Atmel "Butterfly" 
Demo board and have used the butterfly carrerr board to construct 
the same type of testbed. I will let ya know if Bascom works with 
the SPI on the ATmega 169 Demo Board.

   I tried to control the SS pim manually also...

Thanks for any help...!!!   Testfile follows......

'first test program for ATmega-128 core...  (started 11-22-04)
'     started SPI testing after bulding an assed-on board to hold 
the Atmel 25P1024C (12-02-04)

'$sim   'Uncomment this line to get rid of delays during sim runs...

'this is the "Declareing" section

Dim Byte_reg As Byte

Dim Flash_status_byte As Byte
Dim Hex_string As String * 4

Declare Sub Gfs


'this is the "init" section
Config Portb = Output
Config Portc = Output
Config Lcdpin = Pin , Db4 = Portc.4 , Db5 = Portc.5 , Db6 = 
Portc.6 , Db7 = Portc.7 , E = Portc.2 , Rs = Portc.0
Config Spi = Hard , Master = Yes , Polarity = High , Phase = 1 , 
Clockrate = 4 , Noss = 0

Spiinit
Initlcd

'[now init the clock]
Config Date = Mdy , Separator = /       ' ANSI-Format
Config Clock = Soft
Date$ = "11/30/04"
Time$ = "12:00:00"



Enable Interrupts

'start of main program section...
Cursor Off

Do

Cls
Lcd "ATmega 128 MCU"
Lowerline
Lcd "Evaluation Test"
Wait 1

Cls
Byte_reg = 0

Do
Call Gfs
Home
Lcd "Loopcount >"
Lcd Byte_reg
Lowerline
Lcd "Status >"
Lcd Hex(flash_status_byte)
Lcd " "
Lcd Flash_status_byte
Incr Byte_reg
Waitms 250
Loop Until Byte_reg = 10

Cls
Lcd "Date: " ; Date$
Lowerline
Lcd "Time: " ; Time$
Waitms 250


Loop


Gfs:                          'get flash chip status

Flash_status_byte = 05        'read the status reg command for Atmel 
AT25P1024P Flash chip

'Reset Portb.0
Spiout Flash_status_byte , 1
Spiin Flash_status_byte , 1
'Set Portb.0
Return



End

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.