Hey Guys,
I'm trying to interface with the C328R JPEG camera module through UART with the mc9s12dt256 and codewarrior 5.9.
The protocol is to send a SYN message to the camera that is the following 6 bytes: AA 0D 00 00 00 00
Once it connects with the camera, it sends an ACK message to verify. My problem is that i send the SYNC message continually and never get an ACK message. I debug it and set a breakpoint at the start of the ISR for the rx line, but the program runs forever and the interrup never gets generated. Here is the code i have doing this. Do you have any suggestions? Also, remember this is just to test and see if i can get aANY data to send from the camera, i can't get t he interrupt to generate at all.
ORG $FFD6 ; SCI0 interrupt vector setup
DC.W SCI0ISR
MyCode: SECTION
main:
_Startup:
Entry: LDS #__SEG_END_SSTACK ; initialize the stack pointer
ldaa #$00
staa SCI0BDH
ldaa #$09 ; Baud Rate 14,400
staa SCI0BDL ; = 1/2 of the Bus Clock of 4 MHz
ldaa #$2C
staa SCI0CR2
cli
jsr cameraConnection ; connect to the camera.
cameraConnection
jsr sendSYNC
bra cameraConnection
sendSYNC
ldaa #$AA
jsr putchar
ldaa #$0D
jsr putchar
ldaa #$00
jsr putchar
jsr putchar
jsr putchar
jsr putchar
rts
putchar brclr SCI0SR1,#%10000000,putchar ; wait for transmit buffer empty
staa SCI0DRL ; send a character
rts
SCI0ISR
brclr SCI0SR1, %00100000, SCI0ISRdone
ldaa SCI0DRL
jsr putchar
SCI0ISRdone
RTI
The first thing that jumps to my attention is the you are trying to force CW to load the Isr start address in the vector table. I have never found CW allow me to do this, it always gives me an error saying I can;t write there. Try going to the linker file for your target type and adding VECTOR 20 SCI0_ISR at the end, that's how I do it.
The more i analyze it, the more i think its my hardware setup. The development board is a CSMB-12dt256. It only supplies 5 V while the camera is 3.3 V. So i set up a regulator to supply the 3.3 V power to it (and have verified it is getting the correct power). I have also scoped the transmit signal and it is definately transmitting the data, however the data is 0-5 V on the transmit line. On the data sheet of the camera, it says the Tx and Rx lines are 3.3 V (This is UART by the way), however it also says that TTL high level input voltage is min 2.0 V and no max is listed, so I'm guessing that this means the 5 V will be ok on the transmit line (i don't know much about it). I probed the Rx line of the camera and the signal is constant at 3.3 V.
Do i need to do some conditioning to make the Tx line 0-3.3 V? Or could it possibly be an issue with current?
Hello,
You may wish to consider a series diode in each data lead between the camera and the MCU. In each case, the diode is connected with its cathode to the output side, and anode to the input side, and pullups should be enabled at each input, or an external pullup resistor connected to the relevant supply rail.
The diode is present for a different purpose in each case. For the camera output signal, the presence of the diode is used to slightly increase both the logic levels, as applied to the MCU. A standard silicon small signal diode would increase both logic low and logic high levels by 0.6 - 0.7 volts, to better meet the required input threshold levels of the 5 volt device.
When the 5 volt output from the MCU is applied to the data input of the camera, unless the camera input is 5 volt tolerant, there will be an injection current into the input pin, which may be quite large unless current limited by a series resistor. The presence of the injection current can lead to serious latch-up problems. Adding the diode, in this case a small signal Schottky type would be preferred, will eliminate the injection issue by becoming non-conducting whenever the output voltage exceeds the supply voltage at the input pin.
Note that, because each input is not actively driven to a high state, this may limit the maximum baud rate, depending on the pullup resistor values used.
Regards,
Mac
S12 minimum Input High Voltage (VIH) is 0.65*Vdd. Supplying S12 from 5V Vdd, minimum input "1" voltage is 3.25V. Camera output levels can be just little to low. Try enabling pull up on S12 Rx pin.