View previous topic :: View next topic |
Author |
Message |
petros047
Joined: 14 Mar 2012 Posts: 84
|
Posted: Thu May 15, 2014 2:18 pm Post subject: Uart and terminal no correct characters |
|
|
Hello
Is my first time who I send data to my pc
I have write this code :
$regfile = "m168pdef.dat"
$crystal = 1000000
$hwstack = 40
$swstack = 16
$framesize = 32
Config Com1 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Dim I As Word
I = 0
Config Timer1 = Timer , Capture_edge = Rising , Prescale = 1024
Enable Interrupts
Enable Icp1 'enable the interrupt
On Icp1 Fire1
Main:
Do
Print "hello world"
Waitms 55
Loop
End
Fire1:
I = 19531 \ Icr1
I = I * 60
Timer1 = 0
Return
the communication work fine but I dont see hello world but some symbols.
I try other emulator the termite and again I see only symbols or greek letters
How I can solve this?
In my finally program I will send numbers.
For now the interrupt do nothing just check the uart first.
Thank you
(BASCOM-AVR version : 2.0.7.6 , Latest : 2.0.7.7 ) |
|
Back to top |
|
|
bzijlstra
Joined: 30 Dec 2004 Posts: 1179 Location: Tilburg - Netherlands
|
Posted: Thu May 15, 2014 4:23 pm Post subject: $ baud |
|
|
What happens if you just use the $baud command?
Check the help.
Ben Zijlstra |
|
Back to top |
|
|
petros047
Joined: 14 Mar 2012 Posts: 84
|
Posted: Thu May 15, 2014 7:12 pm Post subject: |
|
|
Ok problem solved I have change to 19200 and add external crystal and now works.
Also in hardware I add pullup resistor 4k7 to icp pin.
the working code
$regfile = "m168pdef.dat"
$crystal = 8000000
$hwstack = 40
$swstack = 16
$framesize = 32
$baud = 19200
Config Com1 = 19200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Dim I As Integer
I = 0
Config Timer1 = Timer , Capture_edge = Falling , Prescale = 1024
Enable Interrupts
Enable Icp1 'enable the interrupt
On Icp1 Fire1
Main:
Do
Loop
End
Fire1:
I = 7812 \ Icr1
I = I * 60
Timer1 = 0
Print I
Return |
|
Back to top |
|
|
jodank
Joined: 22 Apr 2014 Posts: 49
|
Posted: Thu May 15, 2014 8:46 pm Post subject: |
|
|
I think your main problem was the diferent baud rate setup between your pc and uC. |
|
Back to top |
|
|
Visovian
Joined: 31 Oct 2007 Posts: 584 Location: Czech
|
Posted: Fri May 16, 2014 6:09 am Post subject: |
|
|
Quote: | $crystal = 1000000
...
Config Com1 = 9600 | With 1 MHz clock you can use at most 4800 baud. |
|
Back to top |
|
|
|