README for example AR1000 code

11/21/3008
Copyright Spark Fun Electronics 2007
Viliam Klein
viliam at sparkfun.com


1)COMPILING THE CODE
	
This example code was written for the Atmega168 AVR processor, running at 8MHz, using an external crystal oscillator. This means that the code will not function properly at different frequency oscillators without modifying the UART setup code. Also, most AVR code is backwards compatible, except for UART setup code. In order to port this example to other AVRs you will need to change the register names in the ioini() function.

The hex file was compiled and created using Programmers Notepad and it is free of errors. Sparkfun uses this compiler as a default and we cannot offer any support on how to compile our code in other compilers. All we can say is that we know our code works, therefore it can be done if the user knows how to tweak their own systems.

2)RUNNING THE CODE
	
The purpose of this code was to create a simple user interface to the AR1000 through a menu display. This means that in order for the code to function, the user must hook the ATMega168 to a serial port before they can use the code. I used the simple AVR 28pin development board: http://www.sparkfun.com/commerce/product_info.php?products_id=29
but there are many other options.

Once the avr is connected to a serial port on a computer, all the user needs to do is open TeraTerm, Hyperterminal or any other terminal program, set the serial port to 9600baud, 8N1, and reset the microcontroller. A menu should immediately show on the terminal screen

3) USING THE CODE
	
To start one of the functions displayed in the menu, the user needs to push the number of the selection they want to use. For option one push 1, option 2, push 2 etc.

=======SEND ARRAY VALUES=======
This function is used to send the current array values to the registers of the ar1000. Position 0 in the array is used to control R00, position 1 is used to control R01, etc. Upon power up, you 	must send the default array values to the AR1000 in order to start the calibration routine of the AR1000. The result of this should be static coming out of the audio channels. 
This function is also used to update the register values. So once the user has modified the array in whatever way they wish, using this function will send the current register values to the AR1000

========READ ARRAY VALUES======
This is used to verify and check the current array values ON THE AVR, not on the register values in the AR1000.

========SET ARRAY VALUES=======
This function is used to modify the values in the array that is used to control the registers in the AR1000. So to change the functionality of the AR1000 (tune, seek, channel, volume etc) the user will first need to modify the appropriate array value, and then use SEND ARRAY VALUES to send the changes to the AR1000. Just changing the array values will NOT change anything on the AR1000.

First the user inputs the array address number to be changed. This should be a 2 digit value corresponding to the hex value of the array address. Legal values are 0x00-0x11. Entering larger values than 0x11 will not cause any changes in the array. The address needs to be inputted using either the numerical keys or LOWER CASE chars a, b, c, d, e, and f. Upper case will not work. 

Once the address is inputed, than the desired value needs to be inputed. This can be any 2 byte hex number. The value needs to be inputted using either the numerical keys or LOWER CASE chars a, b, c, d, e, and f. Upper case will not work. 

=====READ ALL REGISTER VALUES===
This will output all of the register values on the AR1000, including the R/W registers and the read only register. These values are not stored anywhere, they are only displayed.

==========TEST SEEK=============
This function is a demonstration of how to get the AR1000 to seek through radio stations. First the channel and tune bits are set in R2 to 0xB480, or 0b1011010010000000. This corresponds to a channel value of 210 (0b011010010) or a frequency of 210+690=900kHz. 
Then R3 is set to 0xA001, this turns off the seek function and sets the threshold to 1. 
Then the updated register values are sent to the AR1000
 
Once the AR1000 has been updated with the starting channel and the seek as been turned off. The seek bit can be turned on again to initiate a seek. The function sets R03 to 0xE001 and then sends the updated array to the ar1000 again. 

You should now here a radio station on the audio output. 

This is not guaranteed to work the same every time due to different reception factors and radio station signal strength. Please make sure that you have a good antenna soldered to the ant pin (I used a 30 piece of wire, and it worked fine).

For more troubleshooting help, please read the sparkfun forum, or contact tech support at spark at sparkfun.com.


	
