Wednesday, March 29, 2006

~38400 Baud on SCI2 for M68DEMO908GB60

Had better results with using 32 as the prescalar:

//SCI2BDL=0b00100001;//37878, 33 = 20Mhz/16*384000, where BaudRate = clock/(16*prescalar)
SCI2BDL=0b00100000;//39062, 32 = 20Mhz/16*384000, where BaudRate = clock/(16*prescalar)

when

ICGC2_MFD = 7;
ICGC2_RFD = 0;
ICGC1 = 0b00111000;


All jumpers must be set. See page 169 of MC9S08GB60.pdf for additional info.

Data rate verified via serial hookup to RealTerm Serial Capture.

Tuesday, March 28, 2006

Ruby is just so beautiful

took about 90 minutes, since I had to learn about rubyzip:

=begin
# Simple script to retrieve all properties files, package them in the target directory,
# and add a comment to the top and bottom informing developers #to place entries at the bottom
# requires rubyzip (http://rubyzip.sourceforge.net/)
=end

require 'date'
require 'zip/zip'

class Properties_Packager

DECORATION = "#============================================="

HEADER_COMMENT =
DECORATION +
"\n#Please place all new additions at the bottom of the file\n" +
DECORATION

FOOTER_COMMENT =
DECORATION +
"\n#Packaged and processed on " + (Time.now.to_s ) + ". Please place all new entries after this section\n" +
DECORATION

@prop_files
attr_reader :prop_files, :HEADER_COMMENT

def initialize
@prop_files = []
@header_comment
end

private
def legit_file file
! (file.index("env.") != nil ||
file.index("junit") != nil ||
file.index("project.") != nil ||
file.index("#") != nil)
end


public
def obtain_properties_files(directory)
current_dir = Dir.open(directory)

for file in current_dir
next if(file == "." ||
file==".." ||
file=="target")

path = current_dir.path + "/" + file

if File.directory?(path)
obtain_properties_files(path)
else
if (legit_file file and file.index("properties") != nil)
puts "Adding " + path
@prop_files << path
end
end
@prop_files
end
@prop_files
end

def add_comments files
files.each do |file|
contents_buffer = []
current_lines = IO.readlines(file.to_s)

possible_header = current_lines[0]

if(! possible_header.strip.eql? DECORATION)

contents_buffer << HEADER_COMMENT
end

contents_buffer << IO.readlines(file.to_s).to_s
contents_buffer << FOOTER_COMMENT

open_file = File.open(file,"r+")
open_file.puts(contents_buffer)
open_file.close
end
end

def put_files_in_zip files, out_file_name

#if the file exists, erase it
if File.exists?(out_file_name)
File.delete(out_file_name)
puts "DELETED old zip file"
end

zipfile = Zip::ZipFile.new out_file_name, true
files.each do |file|
puts "zipping " + file.to_s
zipfile.add file, file.to_s
end
zipfile.close

end
end

zip_file = 'target/packaged_properties.zip'

packager = Properties_Packager.new
props = packager.obtain_properties_files('src/webapp')
packager.add_comments props
packager.put_files_in_zip props, zip_file

puts "Properties package ready for delivery #{zip_file}"


Thursday, March 23, 2006

Gentoo and Rails 1.0, sqlite3, fastcgi and lighttpd

emerged sqlite3 and sqlite3-ruby
added USE flags, fcgi lighttpd
emerged ruby-fcgi lighttpd
uncommented "mod_fastcgi" and "mod_redirect" in /etc/lighttpd.conf

emerged rails

yankes and configured lserver and lighttpd.conf per http://www.bigbold.com/snippets/posts/show/303

executed "rails todoapp"
copied lighttpd.config to todoapp/config and lserver to todoapp/script
updated config/database.yaml---
development:
adapter: sqlite3
database: db/database_dev.db
test:
adapter: sqlite3
database: db/database_test.db

production:
adapter: sqlite3
database: db/database_prod.db
---

executed "script/generate migration InitialSetup"


updated db/migrate/001_initial_setup.rb---
class InitialSetup < text ="">"some new task", :date =>"11-21-1978", :done =>0
end

def self.down
drop_Table :todos
end
end

execute "rake migrate", and for some reason this hangs the first time, ctrl-c kills but it ran successfully...
execute "script/generate model Todo"

install ajax_scaffold-2.2.1.gem
execute "script/generate ajax_scaffold Todo"
execute "script/lserver"

point browser to http://localhost:8000/Todos

Wednesday, March 15, 2006

baud rate calcuation

CXL04LP3 accelerometer running with interface card at 38400 baud. Need to setup SCI2 in order the run at that rate. Calculation (page 169) is is BAUD RATE = BUSCLK/([SBR12:SBR0] × 16)

The 32K_9S08GB60_Mon.asm file (AN2140SW1) states, ";baud38400: equ 31 ;sets rate to 38,400-0.9% baud". And we know that SCI2BDH_SBR8 is 31(MC9S08GB60.h). So, SCI2BDLH=SCI2BDH_SBR8

Friday, March 03, 2006

MySQL character inserts

Interestingly, if there VARCHAR column with a record containing ',' and the attempt is made to insert ', ', MySQL reports that this is a duplicate key, thereby trimming the insertion. Tested and reproduced on 4.1.3-beta-standard.