Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

uart and high baud

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
krolikbest

Bascom Member



Joined: 02 Jan 2017
Posts: 112

poland.gif
PostPosted: Mon Aug 27, 2018 6:57 pm    Post subject: uart and high baud Reply with quote

Hello

I do some communication between ardunio uno and pm532 (rfid) via UART. With uno is connected also lcd 4*40 i2c. I attach my code, maybe it will be useful for someone. So far i did only reading \\\\\\\"version info\\\\\\\" but it is very simple to create some additional frames to read other infos from pm532. But also I have qeustion at the end of my post Smile

Code:

$regfile = \\\\\\\"m328pdef.dat\\\\\\\"
$crystal = 16000000
$baud = 115200                                                \\\\\\\' use baud rate
$hwstack = 32                                               \\\\\\\' default use 32 for the hardware stack
$swstack = 10                                               \\\\\\\' default use 10 for the SW stack
$framesize = 40                                             \\\\\\\' default use 40 for the frame space


Config I2cdelay = 10
Config Twi = 100000
Config Scl = Portc.5
Config Sda = Portc.4

$lib \\\\\\\"bl_Lcd_i2c.lib\\\\\\\"                                       \\\\\\\' AN #118 library from Kent

\\\\\\\'zmienne ekranu I2C
Dim _lcd_e As Byte
Dim Backlight As Byte
dim zapyt(9) as Byte
dim wake_up(4) as Byte
dim odp(20) as byte
dim m as byte


wake_up(1)=&H55
wake_up(2)=&H00
wake_up(3)=&H00
wake_up(4)=&H00


zapyt(1)=&H00
zapyt(2)=&H00
zapyt(3)=&HFF
zapyt(4)=&H02
zapyt(5)=&HFE
zapyt(6)=&HD4
zapyt(7)=&H02
zapyt(8)=&H2A
zapyt(9)=&H00


\\\\\\\'Przerwanie do odbioru z portu UART
Enable Interrupts
Enable Urxc
On Urxc Odbior

Const Pcf_d4 = 4
Const Pcf_d5 = 5
Const Pcf_d6 = 6
Const Pcf_d7 = 7
Const Pcf_rs = 0
Const Pcf_rw = 1
Const Pcf_e1 = 2
Const Pcf8574_lcd = &H4E                                    \\\\\\\'Defines the address of the I/O expander for LCD


Backlight_on Alias &H08
Backlight_off Alias &H00
Backlight = Backlight_on
_lcd_e = 128

cls
do

 printbin wake_up(1),4
 printbin zapyt(1),9
 wait 1

loop

Odbior:
  m=1
  do
   odp(m)=waitkey()
   incr m
  loop until m=20

  Locate 1 , 1
  lcd \\\\\\\"Version PN532:\\\\\\\"

  Locate 2 , 1
  lcd hex(odp(13));\\\\\\\" \\\\\\\";hex(odp(14));\\\\\\\" \\\\\\\";hex(odp(15));\\\\\\\" \\\\\\\";hex(odp(16));\\\\\\\" \\\\\\\";hex(odp(17));
Return
 


It works, well at least for me Smile
The qestion: as you see there is very high baud because it is needed by pm532. When I use an interrupt Urxc then I have any problem to read frames from pm532. But such construction (all declaraion the same except Urxc interrupt):
Quote:

cls
do
printbin wake_up(1),4
printbin zapyt(1),9

a=ischarwaiting()
if a>0 then

m=1
do
odp(m)=waitkey()
incr m
loop until m=20

Locate 1 , 1
lcd \\\\\\\"Version PN532:\\\\\\\"

Locate 2 , 1
lcd hex(odp(13));\\\\\\\" \\\\\\\";hex(odp(14));\\\\\\\" \\\\\\\";hex(odp(15));\\\\\\\" \\\\\\\";hex(odp(16));\\\\\\\" \\\\\\\";hex(odp(17));

end if
wait 1

loop

doesn\\\\\\\'t work. I don\\\\\\\'t know why. I suppouse the baudrate but maybe this code is wrong?

Martin

(BASCOM-AVR version : 2.0.8.0 , Latest : 2.0.8.1 )
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum