Quantcast
Channel: MCS Electronics Forum
Viewing all 20698 articles
Browse latest View live

BASCOM-AVR Old versions : ATA Hard Drive : NEWTOPIC

$
0
0
hallo Ich brauche Hilfe, um auf der ATA-Fest arbeiten Sie

Share your working BASCOM-AVR code here : A simple WAV file player from an SD card w/double buffering : REPLY

$
0
0
Speak Module now working with my Voice Command recognition unit MIKA :D written all in Bascom. (That`s why I don`t have time for finish speak module for another card type but in my version even Folders implemented) For now 5 voice command can be recognized. When You ask MIKA tell`s You what time is or temperature :P MIKA can switch ON/OFF light in room via RF :P MIKA knows temeperature outside from satellite RF sensor :P When I sort out the code and describe it then I post it here. Maybe I send MIKA for Bascom contest :P You can watch MIKA https://www.youtube.com/watch?v=j7rKYzO9sok or look sometimes on my home page http://bart-projects.cba.pl/mika.html

BASCOM-AVR Old versions : ATA Hard Drive : REPLY

$
0
0
Post you config_AVR_Dos and your mmc file. And which processor are you using? What about your hwstack, softstack and framesize? Ben Zijlstra

BASCOM-AVR : Interrupt problem : NEWTOPIC

$
0
0
Hi, I wrote a test program for a pin-change interrupt using a signal generated by an accelerometer sensor LIS331HH. The program works fine. Now I ported this bit of code into a bigger program and and the interrupt service request (ISR) is not jumped to when the interrupt occurs. Funny thing is if I run the ISR as a subroutine first, the interrupt works flawlessly: This does not work: Enable Interrupts Do nop Loop ....... Int1_launched: Flight_phase = Launch Call Beep(5 , 300 , 300) Return However this code does : Gosub Int1_Launched ‘Note that the label of the IRQ is launched first to make the IRQ work. Enable Interrupts Do nop Loop ..... Int1_launched: Flight_phase = Launch Call Beep(5 , 300 , 300) Return The interrupt is defined as follows: Config Pind.1 = Input Portd_pin1ctrl = &B00_000_010 Portd_int1mask = &B0000_0010 On Portd_int1 Int1_Launched Enable Portd_int1 , Lo Why do I have to run the ISR first in order for the IRQ to work? Any suggestions appreciated! [b:905c84f911][color=red:905c84f911](BASCOM-AVR version : 2.0.7.8 )[/b:905c84f911][/color:905c84f911]

AVR : problems with atmega128 and avr studio 4 : NEWTOPIC

$
0
0
Hi folks, I can not program my atmega128 with avr-studio 4. I bought a few boards with an atmega128 on it and with a isp program connector and a 8 MHz Cristal. One works perfect, but with an other one i was playing with the avr-studio 4 features. i choosed to use an External Xtal with high frequency. After that excersise i always get the next info, and the program does not work in the atmega128: the programming goes okay, but the verifying goes very slow or i get the message: verifying failed: Adress 0x0000, expected: 0x940c, receive:0xffff How can i get to normal operation with that atmega128? Again, i use other ( the same sort) boards for other programs, and they work perfect.... only this one i can not program anymore. when i use the advanced menu of studio 4 tools i get with a working atmega128: int Rcosc.freq: 8Mhz startup 64 ms + 6 ck bootblock 4096 words device sign 1E 97 02 target sw rev = 3.8 calibration type 0xA4 with the problem atmega128 i get: ( and i can not change it) int Rcosc. freq: ext.Xtal high frequency startup 64 ms + 6 ck bootblock 512 words device sign FF FFFF target sw rev = 3.8 calibration type 0xff Please, can anybody help me? Wim

BASCOM-AVR : Interrupt problem : REPLY

$
0
0
You enable the interrupt on the pin within the interrupt. When you run the interrupt first, you are initializing the interrupt hardware. I would suggest moving all of the hardware setup to the main program, before the Do Loop. JC

BASCOM-AVR : Pset to Line : REPLY

$
0
0
Remember you can only have one math function per line, in Bascom. This is a line plotting routine in Bascom, using Bresenham's algorithm. Obviously this isn't the full program, but perhaps it will help get you started. [code:1:0427902b69] Glcdline: 'Draw a Straight Line on the GLCD, Pixel Coordinates. 'Use Bresenham's algorithm. 'On Entry have: (GX1,GY1) and (GX2,GY2) 'GX1, GX2: Columns: 0-127, Left to Right 'GY1, GY2: Rows: 0-63, Top Down 'Supports the Inverse Mode Flag, as does Text. 'Error Checks for valid location prior to plotting, (within GPixSet). 'Uses GPixSet 'Set Pixel Value for subsequent GPixSet routine If I = 1 Then Pv = 0 'Pixel = Off, Inverted Else Pv = 1 'Pixel = On, black on Clear End If 'First look at Delta X & Delta Y, see slope of line, most flat or vert Gdx = Gx2 - Gx1 Gdx = Abs(gdx) Gdy = Gy2 - Gy1 Gdy = Abs(gdy) Vert = 0 'Line is mostly horz, Slope < 45 degrees If Gdy > Gdx Then Vert = 1 'Line is mostly vertical, Slope > 45 deg End If 'If line is mostly vertical, swap the coordinates If Vert = 1 Then Swap Gx1 , Gy1 Swap Gx2 , Gy2 End If 'If line is R to L, then Swap If Gx1 > Gx2 Then Swap Gx1 , Gx2 Swap Gy1 , Gy2 End If Gdx = Gx2 - Gx1 Gdy = Gy2 - Gy1 Gdy = Abs(gdy) Lerr = Gdx / 2 Gly = Gy1 If Gy1 < Gy2 Then Ystep = 1 Else Ystep = -1 End If For Glx = Gx1 To Gx2 'Plot the points If Vert = 1 Then 'Plot (Gly,Glx) Pc = Low(gly) Pr = Low(glx) Else 'Plot (Glx,Gly) Pr = Low(gly) Pc = Low(glx) End If Gosub Gpixset 'Plot the point Lerr = Lerr - Gdy If Lerr < 0 Then Gly = Gly + Ystep Lerr = Lerr + Gdx End If Next Glx Return [/code:1:0427902b69]

BASCOM-AVR : Pset to Line : REPLY

$
0
0
[quote:0e9742e985="mcupwr"] X,Y are words...[/quote:0e9742e985] Think that PSET expects bytes for X and Y.

Share your working BASCOM-AVR code here : A simple WAV file player from an SD card w/double buffering : REPLY

$
0
0
Do you use something like [url=https://www.youtube.com/watch?v=_h0pfZT_vFg]Sensoryinc[/url] module for recognition, or did you also make the hardware? I have still on my to do list to port [url=http://www.geocities.ws/xxxtoytech/Stewart-91.pdf]this[/url] to avr with Bascom. so much to do, so less time..... Using now my Android to voice control everything.

Share your working BASCOM-AVR code here : A simple WAV file player from an SD card w/double buffering : REPLY

$
0
0
as i understand it, MIKA is a HW solution written in BASCOM-AVR. Not using a sensori module. One of the best things i have seen lately.

AVR : problems with atmega128 and avr studio 4 : REPLY

$
0
0
this has been discussed many times before. basically, you have chosen the wrong oscillator so now the micro is expecting a clock signal from an external oscillator. to solve it, apply a clock signal to the xtal input pin, then select the proper oscillator. you could use a ttl generator or the clock output of another working circuit, a 555, etc. for the clock signal.

AVR : problems with atmega128 and avr studio 4 : REPLY

$
0
0
Hi Albertsm, Okay now i understand what is happening. Thank you very much, I will do the extern signal. i will let you know here. Wim

BASCOM-AVR Old versions : ATA Hard Drive : REPLY

$
0
0
ata hard drive compiles fine. ata harddisk does not compile in 2078 because variables have the same name as sub routines. Error : 25 Line : 114 Variable already dimensioned [ATA_RDY] , in File : D:DATAAppsD7BASAVRPROBataATA_harddisk.bas Error : 25 Line : 115 Variable already dimensioned [ATA_BSY] , in File : D:DATAAppsD7BASAVRPROBataATA_harddisk.bas but if you change that, it works too. [code:1:134e4ac0e9] '-------------------------------------------------------------------------------- ' ATA_harddisk - Atmega128 and ATA-harddisk '-------------------------------------------------------------------------------- ' ' BASCOM-AVR IDE Version : 1.11.7.4 ' ' date: october 8 2003 - check also http://members.home.nl/bzijlstra ' ' settings: HW-stack 128. SW-stack 128. Framesize 128 ' Fusebits-settings: DCBA 1111:CKSEL=111X External crystal/resonator high frequency ' ' External access NOT enabled. ' ' Hardware: ATA Hard Drive Controller from www.edtp.com ' $regfile = "m128def.dat" $crystal = 14746000 Const Cdebug = 0 'ATA Dim Ata_byte_read As Byte Dim Ata_word_read As Word Dim Word_read As Word Dim Bata_rdy As Byte Dim Bata_bsy As Byte Dim Atacmd As Byte Dim Atabyte As Byte Dim Ataadr As Byte Dim Result As Byte Dim Device As Byte Dim Ready As Byte 'result ATA_rdy Dim Busy As Byte 'result ATA_bsy Dim Error As Byte 'result ATA_err Dim Request As Byte 'result ATA_data request Dim Tempword As Word Dim X As Byte Dim Lbasector As Long Dim Lbasector_byte As Byte Dim Temp_lbasector As Long Dim Cylinders As Word Dim Heads As Word Dim Sectors As Word Dim Lba_total As Long Port_ata_data_l_ddr Alias Ddra Port_ata_data_h_ddr Alias Ddrc '// CB_DH bits 7-4 OF THE DEVICE/HEAD REGISTER Const Ata_dh_dev0 = &HE0 '// select device 0 LBA MODE Const Ata_dh_dev1 = &HF0 '// select device 1 LBA MODE Const Cmd_identify_device = &HEC Const Cmd_initialize_device_parameters = &H91 Const Cmd_read_sectors = &H20 Const Cmd_recalibrate = &H10 Const Cmd_write_sectors = &H30 '//ATA I/O PORT FUNCTIONS AND ADDRESS DEFINITIONS '//*CONTROL BLOCK REGISTERS '// RESET '// |DIOW '// ||DIOR '// |||DA0 '// ||||DA1 '// |||||DA2 '// ||||||CS0 '// |||||||CS1 '// |||||||| Const Ata_io_hiz = &B11111111 Const Ata_io_astat = &B11101110 Const Ata_io_devicecntl = &B11101110 '//*COMMAND BLOCK REGISTER ADDRESSES Const Ata_io_data = &B11100001 Const Ata_io_error = &B11110001 Const Ata_io_features = &B11110001 Const Ata_io_sectorcnt = &B11101001 Const Ata_io_sectornum = &B11111001 Const Ata_io_cyl_l = &B11100101 Const Ata_io_cyl_h = &B11110101 Const Ata_io_device_head = &B11101101 Const Ata_io_status = &B11111101 Const Ata_io_cmd = &B11111101 Const Ata_intrq = &H01 Const Ata_dior = 5 Const Ata_diow = 6 Const Ata_reset = 7 '//ATMega128 PIN DEFINITIONS '//ATA Drive Port_ram_cntrl_ddr Alias Ddrg Port_ram_cntl Alias Portg Port_ata_data_l_out Alias Porta Port_ata_data_h_out Alias Portc Port_ata_data_l_in Alias Pina Port_ata_data_h_in Alias Pinc Port_ata_io_cntl_ddr Alias Ddrf Port_ata_io_cntl Alias Portf Const Debu_g = 0 'for Debu_g purpose Declare Sub Ata_hard_reset Declare Sub Avr_databus_in Declare Sub Avr_databus_out Declare Sub Ata_select_device(byval Device As Byte) Declare Sub Recalibrate Declare Sub Ata_set_io_addr(byval Ataaddr As Byte) Declare Sub Ata_write_byte(byval Atabyte As Byte) Declare Sub Ata_send_cmd(byval Atacmd As Byte) Declare Sub Ata_write_pulse Declare Sub Ata_get_status_byte Declare Sub Init_ata Declare Sub Ata_identifier Declare Sub Ata_rdy Declare Sub Ata_bsy Declare Sub Ata_err Declare Sub Ata_read_word Declare Sub Ata_drq Declare Sub Ata_write_sector Declare Sub Ata_read_sector Declare Sub Ata_helper Declare Sub Sram_eth_off Main: Open "comd.3:57600,8,n,1" For Output As #1 'Open "comd.2:9600,8,n,1" For Input As #2 Print #1 , "Spinning UP......" Wait 20 ' spinning up... Port_ata_io_cntl_ddr = &HFF ' portf all output Call Init_ata Call Ata_identifier Wait 5 Lbasector = &H100 Call Ata_write_sector Lbasector = &H100 Call Ata_read_sector Print #1 , "STOP" Stop End '****************************************************************** '* PERFORM HARDWARE RESET '* This routine toggles ATA RESET line low for 10ms. '****************************************************************** Sub Ata_hard_reset #if Debu_g Print #1 , "Routine Ata_hard_reset" #endif Call Sram_eth_off Call Avr_databus_in Port_ata_io_cntl = Ata_io_hiz Reset Port_ata_io_cntl.ata_reset Waitms 100 Set Port_ata_io_cntl.ata_reset Waitms 1 Call Ata_rdy End Sub '****************************************************************** '* Switch databus to input '****************************************************************** Sub Avr_databus_in #if Debu_g Print #1 , "Routine Avr_databus_in" #endif Port_ata_data_l_ddr = &H00 Port_ata_data_h_ddr = &H00 Waitms 1 End Sub '****************************************************************** '* Switch databus to output '****************************************************************** Sub Avr_databus_out #if Debu_g Print #1 , "Routine Avr_databus_out" #endif Port_ata_data_l_ddr = &HFF Port_ata_data_h_ddr = &HFF Waitms 10 End Sub '****************************************************************** '* READ STATUS BYTE '* Read ATA status byte. '****************************************************************** Sub Ata_get_status_byte #if Debu_g Print #1 , "Routine Ata_get_status_byte" #endif Call Avr_databus_in Port_ata_io_cntl = Ata_io_status Reset Port_ata_io_cntl.ata_dior Waitus 1 Ata_byte_read = Port_ata_data_l_in Set Port_ata_io_cntl.ata_dior Port_ata_io_cntl = Ata_io_hiz Call Avr_databus_in End Sub '****************************************************************** '* INITIALIZE DRIVE '* This routine assumes Drive 0 is the only drive attached. '****************************************************************** Sub Init_ata #if Debu_g Print #1 , "Routine Init_ata" #endif Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Ready = 0 : While Ready = 0 : Call Ata_rdy : Wend Call Ata_hard_reset Waitms 10 Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Ready = 0 : While Ready = 0 : Call Ata_rdy : Wend Call Ata_select_device(0) Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Ready = 0 : While Ready = 0 : Call Ata_rdy : Wend Call Recalibrate Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Call Ata_set_io_addr(ata_io_sectorcnt) Call Ata_write_byte(&H3f) Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Call Ata_set_io_addr(ata_io_device_head) Call Ata_write_byte(&Haf) Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Call Ata_send_cmd(cmd_initialize_device_parameters) Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Call Ata_err If Error = 1 Then Print #1 , "Error" Else Print #1 , "Drive READY" End If End Sub '****************************************************************** '* IDENTIFY ATA DEVICE '* This routine assumes Drive 0 is the target drive. '****************************************************************** Sub Ata_identifier #if cDebug Print #1 , "Routine Ata_identifier" #endif Call Ata_send_cmd(cmd_identify_device) Waitms 1 Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Request = 0 : While Request = 0 : Call Ata_drq : Wend Call Ata_read_word Word_read = Ata_word_read Tempword = Word_read And &H8000 If Tempword = &H8000 Then Print #1 , "ATAPI Device Detected" Else Print #1 , "ATA Device detected" End If Tempword = Word_read And &H0080 If Tempword = &H0080 Then Print #1 , "Removable Media Device Detected" End If Tempword = Word_read And &H0040 If Tempword = &H0040 Then Print #1 , "Nonremovable Media Device Detected" End If Call Ata_read_word Cylinders = Ata_word_read Print #1 , "Number of Cylinders = " ; Cylinders Call Ata_read_word ' skip one Call Ata_read_word Heads = Ata_word_read Print #1 , "Number of logical heads = " ; Heads For X = 0 To 2 Call Ata_read_word Next X Sectors = Ata_word_read Print #1 , "Number of logical sectors per track " ; Sectors End Sub '****************************************************************** '* SELECT ATA DEVICE '* This routine defaults to Drive 0 as the target drive. '****************************************************************** Sub Ata_select_device(byval Device As Byte) #if cDebug Print #1 , "Routine Ata_select_device " ; Device #endif Port_ata_io_cntl = Ata_io_device_head Select Case Device Case 0 : Call Ata_write_byte(ata_dh_dev0) Case 1 : Call Ata_write_byte(ata_dh_dev1) Case Else : Call Ata_write_byte(ata_dh_dev0) End Select End Sub '****************************************************************** '* Recalibrate routine '****************************************************************** Sub Recalibrate #if cDebug Print #1 , "Routine Recalibrate" #endif Call Ata_send_cmd(cmd_recalibrate) End Sub '****************************************************************** '* SET ATA I/O ADDRESS '* This routine sets the ATA I/O address. '****************************************************************** Sub Ata_set_io_addr(byval Ataaddr As Byte) #if cDebug Print #1 , "Routine Ata_set_io_addr " ; Ataadr #endif Port_ata_io_cntl = Ataaddr End Sub '****************************************************************** '* WRITE A BYTE TO THE ATA I/O '* This routine writes a byte on the lower 8 bits of the data bus. '****************************************************************** Sub Ata_write_byte(byval Atabyte As Byte) #if cDebug Print #1 , "Ata_write_byte " ; Atabyte #endif Call Avr_databus_out Port_ata_data_l_out = Atabyte Call Ata_write_pulse Port_ata_io_cntl = Ata_io_hiz Call Avr_databus_in End Sub '****************************************************************** '* SEND ATA COMMAND '* Sends an ATA command out of lower 8 bits of data bus. '****************************************************************** Sub Ata_send_cmd(byval Atacmd As Byte) #if cDebug Print #1 , "Routine Ata_send_cmd " ; Atacmd #endif Port_ata_io_cntl = Ata_io_cmd Call Avr_databus_out Port_ata_data_l_out = Atacmd Call Ata_write_pulse Port_ata_io_cntl = Ata_io_hiz Call Avr_databus_in End Sub '****************************************************************** '* SEND write pulse '****************************************************************** Sub Ata_write_pulse #if cDebug Print #1 , "Routine Ata_write_pulse" #endif Reset Port_ata_io_cntl.ata_diow Waitus 1 Set Port_ata_io_cntl.ata_diow End Sub '****************************************************************** '* CHECK ATA BUSY BIT '* Checks READY status bit. '* Returns 1 if device is busy. '****************************************************************** Sub Ata_bsy #if cDebug Print #1 , "Routine Ata_bsy" #endif Call Ata_helper If Ata_byte_read.7 = 1 Then Busy = 1 Else Busy = 0 End If End Sub '****************************************************************** '* CHECK ATA ERROR BIT '* Checks READY status bit. '* Returns 1 if device is reporting an error condition. '****************************************************************** Sub Ata_err #if cDebug Print #1 , "Routine Ata_err" #endif Call Ata_helper If Ata_byte_read.0 = 1 Then Error = 1 Else Error = 0 End If End Sub '****************************************************************** '* CHECK ATA READY BIT '* Checks READY status bit. '* Returns 1 if device is ready. '****************************************************************** Sub Ata_rdy #if cDebug Print #1 , "Routine Ata_rdy" #endif Call Ata_helper If Ata_byte_read.6 = 1 Then Ready = 1 Else Ready = 0 End If End Sub '****************************************************************** '* CHECK ATA DRQ BIT '* Checks READY status bit. '* Returns 1 if device is requesting service. '****************************************************************** Sub Ata_drq Call Ata_helper If Ata_byte_read.3 = 1 Then Request = 1 Else Request = 0 End If End Sub '****************************************************************** '* CHECK ATA READY ERROR BUSY DRQ BIT helper routine '****************************************************************** Sub Ata_helper Call Avr_databus_in Waitus 1 Port_ata_io_cntl = Ata_io_status Reset Port_ata_io_cntl.ata_dior Waitus 1 Ata_byte_read = Port_ata_data_l_in Set Port_ata_io_cntl.ata_dior Port_ata_io_cntl = Ata_io_hiz End Sub '****************************************************************** '* READ WORD FROM ATA DEVICE '* This routine does not use SRAM as a buffer. '****************************************************************** Sub Ata_read_word Call Avr_databus_in Port_ata_io_cntl = Ata_io_data Reset Port_ata_io_cntl.ata_dior Waitus 1 Ata_byte_read = Port_ata_data_h_in Ata_word_read = Ata_byte_read Shift Ata_word_read , Left , 8 Ata_byte_read = Port_ata_data_l_in Ata_word_read = Ata_word_read + Ata_byte_read Set Port_ata_io_cntl.ata_dior Port_ata_io_cntl = Ata_io_hiz End Sub '****************************************************************** '* WRITE A SECTOR '* device = 0x00 or 0x01 //// '* This routine writes an LBA-addressed sector. '****************************************************************** Sub Ata_write_sector Temp_lbasector = Lbasector And &H0FFFFFFF Call Ata_set_io_addr(ata_io_device_head) Shift Temp_lbasector , Right , 24 Temp_lbasector = Temp_lbasector Or &HE0 Lbasector_byte = Temp_lbasector Call Ata_write_byte(lbasector_byte) Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Call Ata_set_io_addr(ata_io_cyl_h) Temp_lbasector = Lbasector Shift Temp_lbasector , Right , 16 Lbasector_byte = Temp_lbasector Call Ata_write_byte(lbasector_byte) Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Call Ata_set_io_addr(ata_io_cyl_l) Temp_lbasector = Lbasector Shift Temp_lbasector , Right , 8 Lbasector_byte = Temp_lbasector Call Ata_write_byte(lbasector_byte) Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Call Ata_set_io_addr(ata_io_sectornum) Lbasector_byte = Lbasector Call Ata_write_byte(lbasector_byte) Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Call Ata_set_io_addr(ata_io_sectorcnt) Call Ata_write_byte(1) Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Call Ata_send_cmd(cmd_write_sectors) Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Request = 0 : While Request = 0 : Call Ata_drq : Wend For X = 0 To 255 Port_ata_io_cntl = Ata_io_data Call Avr_databus_out Port_ata_data_l_out = X Port_ata_data_h_out = 255 - X Call Ata_write_pulse Waitus 1 Busy = 1 While Busy = 1 Call Ata_bsy Wend Next X Call Avr_databus_in Print #1 , "Ready writing 256 word to harddisk" End Sub '****************************************************************** '* READ A SECTOR '* device = 0x00 or 0x01 '* This routine reads an LBA-addressed sector into a SRAM page. '****************************************************************** Sub Ata_read_sector Temp_lbasector = Lbasector And &H0FFFFFFF Call Ata_set_io_addr(ata_io_device_head) Shift Temp_lbasector , Right , 24 Temp_lbasector = Temp_lbasector Or &HE0 Lbasector_byte = Temp_lbasector Call Ata_write_byte(lbasector_byte) Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Call Ata_set_io_addr(ata_io_cyl_h) Temp_lbasector = Lbasector Shift Temp_lbasector , Right , 16 Lbasector_byte = Temp_lbasector Call Ata_write_byte(lbasector_byte) Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Call Ata_set_io_addr(ata_io_cyl_l) Temp_lbasector = Lbasector Shift Temp_lbasector , Right , 8 Lbasector_byte = Temp_lbasector Call Ata_write_byte(lbasector_byte) Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Call Ata_set_io_addr(ata_io_sectornum) Lbasector_byte = Lbasector Call Ata_write_byte(lbasector_byte) Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Call Ata_set_io_addr(ata_io_sectorcnt) Call Ata_write_byte(1) Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Call Ata_send_cmd(cmd_read_sectors) Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Request = 0 : While Request = 0 : Call Ata_drq : Wend For X = 0 To 255 Call Avr_databus_in Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Port_ata_io_cntl = Ata_io_data Reset Port_ata_io_cntl.ata_dior Waitms 1 Print #1 , Port_ata_data_l_in ; Print #1 , " "; Print #1 , Port_ata_data_h_in ; Print #1 , " "; Waitms 1 Set Port_ata_io_cntl.ata_dior Port_ata_io_cntl = Ata_io_hiz Busy = 1 : While Busy = 1 : Call Ata_bsy : Wend Next X Print #1 , "Ready reading 256 word info from harddisk" End Sub Sub Sram_eth_off ' Disable SRAM on ATA Harddrive controller Set Portg.0 ' WR Set Portg.1 ' RD Reset Portg.0 ' LE ' Disable the RTL8019AS on ATA Harddrive controller Reset Porte.2 ' RSTDRV Set Porte.3 ' IOWB Set Porte.4 ' IORB End Sub [/code:1:134e4ac0e9] the errors you see are when using a channel # without opening it first. for example : print #2,"test" without the OPEN "COM1:" for binary as #2

BASCOM-AVR : Problem with SPI communication : NEWTOPIC

$
0
0
Hello I'm developing firmware on device that use C1101 Transceiver. The device is already working. I should only rewrite code for add new functionality. My test read 2 time the same Rom Register and make confrontation but not work because stop on while cicle. Can you help me? Thanks '********************************* 'Direttive al compilatore '********************************* $Regfile="m48pdef.dat" $Crystal=8000000 $hwstack=40 $swstack=16 $framesize=32 '********************************* Open "COMB.0:57600,8,n,1" For Output As #1 Open "COMB.1:57600,8,n,1" For Input As #2 Print #1 , "CC1101 TEST BOARD" CONFIG Spi = Hard , Interrupt = Off , Data Order = Msb , Master = Yes , Polarity = Low , Phase = 0 , Clockrate = 16, NOSS = 0 SPIINIT Byte_Ricevuto_1 = 11 Byte_Ricevuto_2 = 22 'READ 1 SET LED_ROSSO RESET CHIP_SELECT Print #1, "Entro nel While" while PINB.4=1 wend Print #1, "Uscito dal While" SPIout Reg_Part_Number, 1 SPIin Byte_Ricevuto_1, 1 SET CHIP_SELECT waitms 200 RESET LED_ROSSO Wait 1 'READ 2 SET LED_VERDE RESET CHIP_SELECT SPIout Reg_Part_Number, 1 SPIin Byte_Ricevuto_2, 1 SET CHIP_SELECT waitms 200 RESET LED_VERDE waitms 400 IF Byte_Ricevuto_1 = Byte_Ricevuto_2 THEN Print #1, "PRIMA LETTURA"; Byte_Ricevuto_1 Print #1, "SECONDA LETTURA"; Byte_Ricevuto_2 Print #1, "" SET LED_ROSSO WAIT 10 END IF Example followed: ----------------------------------------------------------------- [i:0f34045cbd]unsigned char CC1101::ReadReg(unsigned char addr) { unsigned char x; wait(0.000005); _csn = 0; wait(0.000002); while (_RDmiso); _spi.write(addr | READ_SINGLE); x = _spi.write(0); wait(0.000002); _csn = 1; return x; }// ReadReg[/i:0f34045cbd] --------------------- --------------------------------------------------------------- [i:0f34045cbd]byte CC1101::readReg(byte regAddr, byte regType) { byte addr, val; addr = regAddr | regType; cc1101_Select(); // Select CC1101 wait_Miso(); // Wait until MISO goes low spi.send(addr); // Send register address val = spi.send(0x00); // Read result cc1101_Deselect(); // Deselect CC1101 return val; }[/i:0f34045cbd] ---------------------------------------------------------------- [b:0f34045cbd][color=red:0f34045cbd](BASCOM-AVR version : 2.0.7.8 )[/b:0f34045cbd][/color:0f34045cbd]

Share your working BASCOM-AVR code here : A simple WAV file player from an SD card w/double buffering : REPLY

$
0
0
Yes. I made it from zero after watch video on EEVBlog about voice recognition. Then I get idea "so it will be nice build something new" :D Talking watches talk periodically or when alarm is set but my clock talk when You ask for it :D This can be usefull. When I start I don`t know that YX5300 module You can buy for 6$ with free shipping :D but now I can assembly code for voice recognition with SD card routines for speaking and much more because my code is slim - I think :D For example now I`m using 12 pictures with RLE for small code size and this "big font" takes only 3KB Every project is a big self learning. I learn a lot about OP amps :D when I try to build my AGC microphone. I have base to start some tests and improove as much as possible for 8 bit uC. "Debug" command is my best friend :lol: I have much fun :D

BASCOM-AVR : Interrupt problem : REPLY

$
0
0
Hi, thanks for the remark, below the run down of the INC files. The definition of the interruot hardware is in the QuadAnnt_config.inc file which is before the main program in the QuadAnt2015 file. The Interrupt service routine (ISR) is at the end in the main program. It only sounds a beeper and changes a single variable, no interrupt is enabled within this ISR. so how does this initialize the interrupt hardware? $include "QuadAnt_Variables.inc" 'Definition of variables and eeprom $include "QuadAnt_CONFIG.inc" 'Configuration settings $include "QuadAnt2015.inc" 'Main program $include "Quadant_menu.inc" 'Menu for communication with Android device $include "Acceleration.inc" 'Initialisation of accelerometer thanks, Allard

BASCOM-AVR : Problem with SPI communication : REPLY

$
0
0
you use : NOSS = 0 this means bascom handles the SS signal. Maybe that is why you have CHIP_SELECT, but i do not see any definition for that pin. your code will only work when CHIP_SELECT is not the chip SS pin. i do not get the original code. i see _csn = 1; but also cc1101_Select(); i guess they control the same pin? i also do not get why to wait for miso low? it is all handled by the protocol. Then there are waits (in us i guess). I would recommend to read the data sheet. and then use the bascom spi accordingly. when the clock rate of the SPI and the mode matches, there is no point in waiting for levels and put in delays. when working with SPI it always works the same : you connect the proper pins. you chose the right mode, you init the pins for the proper level. you either select CS pin, or let bascom handle it (NOSS) and you write/read data. In order to read a byte, you must write some value. When done you deselect the CS.

AVR : problems with atmega128 and avr studio 4 : REPLY

$
0
0
Okay Mark, Problem is solved now. I put a 0.5 MHz 6 Volt top top signal generator to xtal1 pin and then wrote with studio 4 the internal oscillator to the avr. so... i am very glad.. again thank you very much albert!! Wim

BASCOM-AVR : Problem with SPI communication : REPLY

$
0
0
Hello With software SPI I see something on oscilloscope... I will show you PROTEUS simulation of the follow code. It write then read and finally compare the value. The register is 0x04 SYNC1 '//////////////////////////////////////////// ' SPI SEND and RECEIVE COMMAND '//////////////////////////////////////////// '********************************* 'Direttive al compilatore '********************************* $Regfile="m48pdef.dat" $Crystal=8000000 $hwstack=40 $swstack=16 $framesize=32 '********************************* '$Include "CC1101 REGISTER.inc" Open "COMB.0:57600,8,n,1" For Output As #1 Open "COMB.1:57600,8,n,1" For Input As #2 Print #1 , "CC1101 TEST BOARD" Config Spi = Soft , Din = Pinb.3 , Dout = Portb.4 , Ss = Portb.2 , Clock = Portb.5 SPIINIT DECLARE SUB CONFRONTA_DUE_LETTURE() DECLARE SUB SCRIVI_LEGGI_E_CONFRONTA() LED_ROSSO Alias PortD.3 CONFIG LED_ROSSO = Output LED_VERDE Alias PortC.2 CONFIG LED_VERDE = Output CHIP_SELECT Alias Portb.2 CONFIG CHIP_SELECT = Output Dim Reg_Part_Number as Byte Dim Reg_Curr_Version as Byte Dim Reg_Sync_W as Byte Dim Reg_Sync_R as Byte Dim Byte_Ricevuto_1 as Byte Dim Byte_Ricevuto_2 as Byte Dim Valore_Scritto as Byte Dim Valore_Letto as Byte Dim S As String * 8 'Dal Datasheet table 43 '0x04 SYNC1 Sync word, high byte '[7] := Header --> 1 '[6] := Burst --> 0 '[5-0] := Indirizzo Registro --> 0x00 --> 000100 '[Byte completo] = 00000100 S = "00000100" Reg_Sync_W = binval (S) 'Dal Datasheet table 43 '0x04 SYNC1 Sync word, high byte '[7] := Header --> 1 '[6] := Burst --> 0 '[5-0] := Indirizzo Registro --> 0x00 --> 000100 '[Byte completo] = 00000100 S = "10000100" Reg_Sync_R = binval (S) 'Dal Datasheet table 44: '0x30 (0xF0) PARTNUM Part number '[7] := Header --> 1 '[6] := Burst --> 0 '[5-0] := Indirizzo Registro --> 0x30 --> 110000 '[Byte completo] = 10110000 S = "10110000" Reg_Part_Number = binval (S) '0x31 (0xF1) VERSION Current version number '[7] := Header --> 1 '[6] := Burst --> 0 '[5-0] := Indirizzo Registro --> 0x30 --> 110001 '[Byte completo] = 10110001 S = "10110001" Reg_Curr_Version = binval (S) DO 'CALL CONFRONTA_DUE_LETTURE CALL SCRIVI_LEGGI_E_CONFRONTA Wait 1 LOOP '_______________________________________________________________________________________ SUB CONFRONTA_DUE_LETTURE() Byte_Ricevuto_1 = 11 Byte_Ricevuto_2 = 22 'READ 1 SET LED_ROSSO RESET CHIP_SELECT while PINB.3=1 wend SPIout Reg_Part_Number, 1 SPIin Byte_Ricevuto_1, 1 SET CHIP_SELECT waitms 200 RESET LED_ROSSO Wait 1 'READ 2 SET LED_VERDE RESET CHIP_SELECT while PINB.3=1 wend SPIout Reg_Part_Number, 1 SPIin Byte_Ricevuto_2, 1 SET CHIP_SELECT waitms 200 RESET LED_VERDE waitms 400 IF Byte_Ricevuto_1 = Byte_Ricevuto_2 THEN Print #1, "PRIMA LETTURA= "; Byte_Ricevuto_1 Print #1, "SECONDA LETTURA= "; Byte_Ricevuto_2 Print #1, "" SET LED_ROSSO WAIT 5 RESET LED_ROSSO END IF END SUB '_______________________________________________________________________________________ SUB SCRIVI_LEGGI_E_CONFRONTA() Valore_Scritto = 11 Valore_Letto = 22 'WRITE ROSSO SET LED_ROSSO RESET CHIP_SELECT while PINB.3=1 wend SPIout Reg_Sync_W, 1 SPIout Valore_Scritto, 1 SET CHIP_SELECT Waitms 200 RESET LED_ROSSO Print #1, "VALORE SCRITTO= "; Valore_Scritto 'READ VERDE SET LED_VERDE RESET CHIP_SELECT while PINB.3=1 wend SPIout Reg_Sync_R, 1 SPIin Valore_Letto, 1 SET CHIP_SELECT waitms 200 RESET LED_VERDE Print #1, "VALORE LETTO= "; Valore_Letto Print #1, "" IF Valore_Scritto = Valore_Letto THEN Print #1, "VALORI UGUALI= " SET LED_ROSSO WAIT 5 RESET LED_ROSSO WAIT 1 END IF END SUB

BASCOM-AVR : Xmega port input pullup not work : NEWTOPIC

$
0
0
As the topic. I have a problem with atxmega128a4u, ports d.0 to d.4, are connected to the buttons. Buttons short to gnd. The program works but the ports are not pullup and hang their condition is random. Here's what I checked none of the codes did not want to work. [code:1:07a311ccba] Config Pind.0 = Input Config Xpin = Portd.0 , Outpull = Pullup , Sense = Falling [/code:1:07a311ccba] [code:1:07a311ccba] Config Pind.0 = Input Porte_pin0ctrl=&B00_011_000 [/code:1:07a311ccba] [code:1:07a311ccba] Config Pind.0 = Input set portd.0 [/code:1:07a311ccba] Any suggestions? [b:07a311ccba][color=red:07a311ccba](BASCOM-AVR version : 2.0.7.5 , Latest : 2.0.7.8 )[/b:07a311ccba][/color:07a311ccba]
Viewing all 20698 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>