View previous topic :: View next topic |
Author |
Message |
radan
Joined: 06 Jan 2007 Posts: 35
|
Posted: Wed Apr 01, 2009 6:19 am Post subject: COM port & videomatrix 16x64 - HELP! |
|
|
Program from a computer via COM port to transmit videomatritsu 16x64 LEDs to the prepared information. In the main loop controller occurs receiving data. The timer is handling the dynamic scan. There is a problem - information occasionally go astray, broken image, or disappear altogether. Then everything is restored. Data one-sided, so there is a presumption that the information is transmitted with errors. Moreover, the 9600 flies less than 115 K. The delay between the transmitted data does not help. Below are some code in VB from the computer and BASCOM from the controller. Can someone experienced with this? Or how to organize the verification of the data?
Code: |
'+++VB6+++
Public Sub OutCom() ' 20 мс
MSComm1.Output = "W" ' Start Mark
For c = 1 To 128
MSComm1.Output = Chr(buf_COM(c))
Next c
End Sub
|
Code: |
'+++BASCOM 1.11.9.3+++
$regfile = "m16def.dat" $crystal = 11059200
$baud = 9600
Config Timer2 = Timer , Prescale = 64
On Timer2 Timer0isr ' Timer0 Auto Reload Timer Mode
Enable Timer2 ' Enable Timer0
Enable Interrupts ' Enable All Interrupt
Start Timer2
Config Portb = Output
Config Porta = Output
Dim Kolzo As Byte
Dim Yyy As Byte
Dim Zzz As Byte
Dim Z1 As Byte
Dim Z2 As Byte
Dim Picsel(128) As Byte
Dim Temp As Byte
'Dim Comdata As Byte
Dim Base As Byte
Dim Index As Byte
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Do
Base = Inkey()
If Base = "W" Then
For Index = 1 To 128
Temp = Waitkey()
Picsel(index) = Temp
Next Index
End If
Loop
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Timer0isr:
Porta.3 = 1
Select Case Kolzo
Case 0 : Z1 = 1 ': Z2 = 8
Case 1 : Z1 = 9 ': Z2 = 16
Case 2 : Z1 = 17 ': Z2 = 24
Case 3 : Z1 = 25 ': Z2 = 32
Case 4 : Z1 = 33 ': Z2 = 40
Case 5 : Z1 = 41 ': Z2 = 48
Case 6 : Z1 = 49 ': Z2 = 56
Case 7 : Z1 = 57 ': Z2 = 64
Case 8 : Z1 = 65 ': Z2 = 72
Case 9 : Z1 = 73 ': Z2 = 80
Case 10 : Z1 = 81 ': Z2 = 88
Case 11 : Z1 = 89 ': Z2 = 96
Case 12 : Z1 = 97 ': Z2 = 104
Case 13 : Z1 = 105 ': Z2 = 112
Case 14 : Z1 = 113 ': Z2 = 120
Case 15 : Z1 = 121 ': Z2 = 128
End Select
Z2 = Z1 + 7
For Zzz = Z1 To Z2
For Yyy = 0 To 7
Porta.2 = 0
Porta.1 = 0
Porta.0 = Picsel(zzz).yyy 'DATA
Porta.1 = 1
Porta.2 = 1
Next
Next
Portb = 15 - Kolzo
Porta.3 = 0
Incr Kolzo
If Kolzo = 16 Then Kolzo = 0
return
|
|
|
Back to top |
|
|
Antony(uk)
Joined: 26 Jun 2006 Posts: 275 Location: Devon UK
|
Posted: Wed Apr 01, 2009 6:47 am Post subject: |
|
|
Hi
Have a look @
$hwstack = ??
$swstack = ??
$framesize = ??
Have you configured in Options
If using data and loseing it can be the above.
Regards Antony(UK) |
|
Back to top |
|
|
tasosstr
Joined: 05 Jan 2005 Posts: 48
|
Posted: Wed Apr 01, 2009 7:32 am Post subject: |
|
|
Hi i thing you need to delay the data from the vb6 so the atmel can have the time to receive all data, so try:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Sub OutCom() ' 20 мс
MSComm1.Output = "W" ' Start Mark
sleep 50
For c = 1 To 128
MSComm1.Output = Chr(buf_COM(c))
sleep 50
Next c
End Sub |
|
Back to top |
|
|
radan
Joined: 06 Jan 2007 Posts: 35
|
Posted: Wed Apr 01, 2009 9:54 am Post subject: ??? |
|
|
Has installed:
$hwstack = 256
$swstack = 256
$framesize =64.
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Sub OutCom() ' 20 мс
MSComm1.Output = "W" ' Start Mark
sleep 50
For c = 1 To 128
MSComm1.Output = Chr(buf_COM(c))
sleep 50
Next c
End Sub
Nothing do not change ... |
|
Back to top |
|
|
tasosstr
Joined: 05 Jan 2005 Posts: 48
|
Posted: Wed Apr 01, 2009 8:47 pm Post subject: |
|
|
Sorry but now i see better the code from bascon side, the timer interrupt what does ?
Try to disable this when you receive data. |
|
Back to top |
|
|
radan
Joined: 06 Jan 2007 Posts: 35
|
Posted: Thu Apr 02, 2009 5:43 am Post subject: ??? |
|
|
If I disable the timer, was suspended dynamic matrix display and temporarily disabled. But the data is transferred correctly. But I am not satisfied that at the time of the transfer of data is short damping matrix of LEDs. How can that be? |
|
Back to top |
|
|
tasosstr
Joined: 05 Jan 2005 Posts: 48
|
Posted: Thu Apr 02, 2009 8:52 pm Post subject: |
|
|
So if i understend well you say it is working ok with the disable of timer,
So try to setup the Rx Tx in interrupts area,so when you have an interrupt check this came from timer or from the rx ?
Try to see in the manual for interrupt with the RS232. |
|
Back to top |
|
|
tasosstr
Joined: 05 Jan 2005 Posts: 48
|
Posted: Sat Apr 04, 2009 6:18 pm Post subject: |
|
|
Check on manual for ENABLE
Action
Enable specified interrupt.
Syntax
ENABLE interrupt
Remarks
Interrupt
Description
INT0
External Interrupt 0
INT1
External Interrupt 1
OVF0,TIMER0, COUNTER0
TIMER0 overflow interrupt
OVF1,TIMER1,
COUNTER1
TIMER1 overflow interrupt
CAPTURE1, ICP1
INPUT CAPTURE TIMER1 interrupt
COMPARE1A,OC1A or
COMPARE1, OC1
TIMER1 OUTPUT COMPARE A interrupt
In case of only one compare interrupt
COMPARE1B,OC1B
TIMER1 OUTPUT COMPARE B interrupt
SPI
SPI interrupt
URXC
Serial RX complete interrupt
UDRE
Serial data register empty interrupt
UTXC
Serial TX complete interrupt
SERIAL
Disables URXC, UDRE and UTXC
ACI
Analog comparator interrupt
ADC
A/D converter interrupt |
|
Back to top |
|
|
|