Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20557

BASCOM-AVR : coupling 2 atmega via RS 232 or SPI ? : NEWTOPIC

$
0
0
Dear All, I am kindly asking for your advice how I may proceed. I programmed a ATMega328 ( = CPU A) to control the movement of a stepper motor ( basically creating signals e.g. stepper-clock, direction, halfstep/fullstep) and write position data to a LCD display. As the LCD display is a little bit slow ( this is what I think because the hickup correlates with writing) I decided to write to the LCD Display once every 200 stepper-clocks. I am using the library lcd4busy_anypin.lbx While the motor is in movement this writing to the display causes some hickup in the movement of the stepper motor. I want to avoid this. It sounds ugly. My idea is to use an ATMega 8 ( = CPU B) for handling the display communication. CPU A takes care of the communication with the PC only when motor is not moving. CPU A needs the hardware UART of CPU A for this purpose. CPU A handles also 2 push buttons that have several functions. One function of the pushbuttons is scrolling the display. So CPU A has to transfer to CPU B that a scrolling operation has to be peformed. CPU B receives the data to display during the init routine of CPU A or after a command arrives from the PC. This does not happen very often. The typical operqtion is that the ionformation of the actual position is tranferred after a movement is finished. So CPU B is only listening to CPU A and writing to the display. I see two possibilities: #1: Programming a software RS 232 on CPU A and connect it to the hardware RXD of CPU B. Advantages: This method occupies one pin on each CPU only. On the listening CPU B I can use the all the comfortable BASCOM features for RS 232 including ringbuffer and bytematch. With this kind of operation like catching the frame etc. I have some experience with RS232 communication. Disadvantage : It is relatively slow. #2: Using HW SPI on both CPUs. As far as I could read it in the documentation of the processors, BASCOM help-files and the samples SPI communication is very fast. I need the SPI interface for traferring the code via the programmer into the flash memories. My idea is to connect the CPU via a special cable from one SPI socket to the other. Advantage: very fast data transfer. Disadvantage: Consumption of at least 3 pins on each CPU. I have no experience using the SPI interface. Handling of a ring buffer on CPU B has to be programmed by me. The comfortable BASCOM feaures are not available. If I could send the data in one array of bytes string and read it into one big array of bytes I may come along using an overlay construction. This would help. I started reading about I²C . To my feeling it is like using a cannon against sparrows. Perhaps i am wrong. I am also considering stay with one CPU and speed up the system clock from 6 MHz to e.g. 16 MHz. The operations within the CPU will be handled faster. I doubt that writing the data to the LCD display is performed faster. But it has the advantage that the board will not be so much crowded. Please let me have your advice. best regards Christian [b:99d51fe4fe][color=red:99d51fe4fe](BASCOM-AVR version : 2.0.7.7 )[/b:99d51fe4fe][/color:99d51fe4fe]

Viewing all articles
Browse latest Browse all 20557

Trending Articles



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