Hi.
I have a few problems.
I finnaly got the IRSCI working (echoing). Thanks.
But it ignores my code when i try to send bytes only.. ?
I have also done some testing on writing direct to the flash memory.
I followed the information in datasheet, but i'm not sure i'm doing it correct.
I will not know before i get the IRSCI TX to work.
By the way, Does anybody know where to find a complete interrupt driven uart code for MC68HC908AP64/32/16 ?
Please check my code below and comment what i do wrong.
#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#include "MCUinit.h"
// A pointer to memory where i want to store information.
unsigned char *EEPROM = (unsigned char*)0xF000;
void Delay (int pause) {
int a;
for(a=0;a<pause;a++) {
;
}
}
unsigned char GetByte() {
// This part should read a byte from address 0xF000.
return *EEPROM;
}
void SetByte(unsigned char val) {
// The delays below is not adjusted yet. Maybe i should use a timer.
// This function should store one byte in address 0xF000.
// Tryed to follow the instructions in datasheet.
// Will this code work ?
FLCR |=FLCR_PGM; // Disable program controll bit
*EEPROM=0x01; // Write to the memory area. (Will not be stored.)
Delay(20); // Wait
FLCR |= FLCR_HVEN; // Highvoltage enabled
Delay(100);
*EEPROM=val; // Write byte to flash memory
Delay(200);
FLCR &=~FLCR_PGM; // Disable program controll bit
Delay(20);
FLCR &=~FLCR_HVEN; // Highvoltage disabled
}
void main(void) {
int b=0;
int a=0;
byte tmp;
// Init function produced by Device Initialization in Code Warrior.
MCU_init();
EnableInterrupts;
SetByte(66); // Set the number 66 at address 0xF000
a=GetByte(); // Read the byte on address 0xF000
for(b=0;b<10;b++) {
// Send the byte 10 times to IR UART.
// I am not sure about next part.
while(((IRSCS1 & IRSCS1_SCTE)==IRSCS1_SCTE) && ((IRSCS1 & IRSCS1_TC)==IRSCS1_TC));
// Send the byte to IR uart. Should send ABCDEFGHIJ to the comport.
IRSCDR=a+b;
}
for(;
{
for(b=0;b<100;b++) {
;
}
// The code below works fine
// it echoes back the characters to the terminal connected to uart.
while((IRSCS1 & IRSCS1_SCRF)==0);
tmp=IRSCDR;
IRSCDR=tmp;
}
}
/AlfaMaster
Message Edited by NLFSJ on 2009-08-18 10:00 AM